diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-12-18 18:15:24 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-12-18 18:19:30 +0100 |
commit | 19e41f3f328209bf1c0fa615af442b4c62305b37 (patch) | |
tree | 2505fd1ad3c077ddaa96481881401c0502dd09aa | |
parent | 48b78095ffa8bf349bec312d14812df264cacc32 (diff) | |
download | ghdl-19e41f3f328209bf1c0fa615af442b4c62305b37.tar.gz ghdl-19e41f3f328209bf1c0fa615af442b4c62305b37.tar.bz2 ghdl-19e41f3f328209bf1c0fa615af442b4c62305b37.zip |
libraries: clear last_design_file cache.
-rw-r--r-- | src/libraries.adb | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/src/libraries.adb b/src/libraries.adb index 4a12f825e..243256059 100644 --- a/src/libraries.adb +++ b/src/libraries.adb @@ -35,6 +35,9 @@ package body Libraries is Libraries_Chain : Iir_Library_Declaration := Null_Iir; Libraries_Chain_Last : Iir_Library_Declaration := Null_Iir; + -- Last design_file used. Kept to speed-up operations. + Last_Design_File : Iir_Design_File := Null_Iir; + -- Table of library paths. package Paths is new Tables (Table_Index_Type => Integer, @@ -251,30 +254,38 @@ package body Libraries is begin File := Get_Design_File_Chain (Work_Library); Prev := Null_Iir; - while File /= Null_Iir loop - Next := Get_Chain (File); - if Get_Design_File_Filename (File) = File_Name - and then Get_Design_File_Directory (File) = Dir_Name - then - -- Remove from library. - if Prev = Null_Iir then - Set_Design_File_Chain (Work_Library, Next); - else - Set_Chain (Prev, Next); - end if; - - -- Remove all units from unit hash table. - Unit := Get_First_Design_Unit (File); - while Unit /= Null_Iir loop - Remove_Unit_Hash (Unit); - Unit := Get_Chain (Unit); - end loop; - + loop + if File = Null_Iir then + -- Not found ??? return; end if; + + Next := Get_Chain (File); + exit when Get_Design_File_Filename (File) = File_Name + and then Get_Design_File_Directory (File) = Dir_Name; + Prev := File; File := Next; end loop; + + -- Remove from library. + if Prev = Null_Iir then + Set_Design_File_Chain (Work_Library, Next); + else + Set_Chain (Prev, Next); + end if; + + -- Remove all units from unit hash table. + Unit := Get_First_Design_Unit (File); + while Unit /= Null_Iir loop + Remove_Unit_Hash (Unit); + Unit := Get_Chain (Unit); + end loop; + + -- Clear the Last_Design_File cache. + if Last_Design_File = Design_File then + Last_Design_File := Null_Iir; + end if; end Purge_Design_File; -- Load the contents of a library from a map file. @@ -987,9 +998,6 @@ package body Libraries is raise Internal_Error; end Remove_Unit_From_File; - -- Last design_file used. Kept to speed-up operations. - Last_Design_File : Iir_Design_File := Null_Iir; - -- Add or replace a design unit in the working library. procedure Add_Design_Unit_Into_Library (Unit : in Iir_Design_Unit; Keep_Obsolete : Boolean := False) |