Commit 258e9f91 authored by John van Groningen's avatar John van Groningen
Browse files

optimize abc cache, replace old data with new data, if a file is modified,

instead of adding the new data and keeping the old data
parent 8f89101f
...@@ -79,8 +79,14 @@ Combined path date abccache files ...@@ -79,8 +79,14 @@ Combined path date abccache files
= Read_Version_and_Options file = Read_Version_and_Options file
# (file,dInfo) = ParseABCDependencies file # (file,dInfo) = ParseABCDependencies file
# (_,files) = fclose file files # (_,files) = fclose file files
#! maxi=abccache.maxi
# (cache_index,abccache) = search_path_in_cache path maxi abccache
| cache_index<0
#! abccache = AC_Add path date dInfo abccache #! abccache = AC_Add path date dInfo abccache
= ((cInfo,dInfo,abccache),files) = ((cInfo,dInfo,abccache),files)
#! abccache = {abccache & cache.[cache_index]={c_path=path,c_date=date,c_info=dInfo}}
= ((cInfo,dInfo,abccache),files)
where where
dummyCinf = (False,False,-1,DefaultABCOptions) dummyCinf = (False,False,-1,DefaultABCOptions)
dummyDinf = dummyDepInfo dummyDinf = dummyDepInfo
...@@ -232,21 +238,14 @@ where ...@@ -232,21 +238,14 @@ where
newstuff :: ABCStuff newstuff :: ABCStuff
newstuff = {c_path=path,c_date=date,c_info=info} newstuff = {c_path=path,c_date=date,c_info=info}
UCache :: !ABCStuff !Int !*{!ABCStuff} -> *{!ABCStuff}
UCache e i a = {a & [i] = e}
ParseABCDependencies` :: !Pathname !DATE !*ABCCache !Files -> ((!Bool, !List Modulename, !Maybe ModuleDate, !List ModuleDate, !List LinkObjFileName, !List LinkLibraryName, !*ABCCache/*, !FileInfoCache*/), !Files); ParseABCDependencies` :: !Pathname !DATE !*ABCCache !Files -> ((!Bool, !List Modulename, !Maybe ModuleDate, !List ModuleDate, !List LinkObjFileName, !List LinkLibraryName, !*ABCCache/*, !FileInfoCache*/), !Files);
ParseABCDependencies` path abcdate abccache files ParseABCDependencies` path abcdate abccache files
= AC_Look path abccache files = AC_Look path abccache files
where where
AC_Look path abccache=:{maxi} files AC_Look path abccache=:{maxi} files
# date = abcdate # date = abcdate
# (foundl,abccache) = uSeqArray # (cache_index,abccache) = search_path_in_cache path maxi abccache
(\{c_path,c_date}-> c_path == path && eqDate c_date date) | cache_index<0
(\{c_info}->c_info)
(maxi)
abccache
| isEmpty foundl
# (opened,file,files) = fopen path FReadData files # (opened,file,files) = fopen path FReadData files
| not opened | not opened
# (b,c,d,e,f) = dummyDepInfo # (b,c,d,e,f) = dummyDepInfo
...@@ -255,19 +254,18 @@ where ...@@ -255,19 +254,18 @@ where
# (_,files) = fclose file files # (_,files) = fclose file files
#! abccache = AC_Add path date (b,c,d,e,f) abccache #! abccache = AC_Add path date (b,c,d,e,f) abccache
= ((True,b,c,d,e,f,abccache),files) = ((True,b,c,d,e,f,abccache),files)
# (b,c,d,e,f) = hd foundl # ({c_date,c_info},abccache) = abccache!cache.[cache_index]
| eqDate c_date date
# (b,c,d,e,f)=c_info
= ((True,b,c,d,e,f,abccache),files)
# (opened,file,files) = fopen path FReadData files
| not opened
# (b,c,d,e,f) = dummyDepInfo
= ((False,b,c,d,e,f,abccache),files)
# (file,(b,c,d,e,f)) = ParseABCDependencies file
# (_,files) = fclose file files
#! abccache = {abccache & cache.[cache_index]={c_path=path,c_date=date,c_info=(b,c,d,e,f)}}
= ((True,b,c,d,e,f,abccache),files) = ((True,b,c,d,e,f,abccache),files)
uSeqList f g acc [] = ([],reverse acc)
uSeqList f g acc [h:t]
| f h = ([g h],reverse acc ++ [h:t])
= uSeqList f g [h:acc] t
uSeqArray f g n c
| n < 0 = ([],c)
# (r,c) = c!cache.[n]
| f r = ([g r],c)
= uSeqArray f g (dec n) c
eqDate l r eqDate l r
= l.exists == r.exists = l.exists == r.exists
...@@ -278,6 +276,14 @@ where ...@@ -278,6 +276,14 @@ where
&& l.m == r.m && l.m == r.m
&& l.s == r.s && l.s == r.s
search_path_in_cache :: !{#Char} !Int !*ABCCache -> *(!Int,!*ABCCache)
search_path_in_cache path n c
| n < 0
= (-1,c)
| c.cache.[n].c_path == path
= (n,c)
= search_path_in_cache path (dec n) c
// Find the module depencies in the .abc files // Find the module depencies in the .abc files
dummyDepInfo = (Nil, Nothing, Nil, Nil, Nil) dummyDepInfo = (Nil, Nothing, Nil, Nil, Nil)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment