From 2f95e4d829ed1452f160fa94a9126c71fde2140f Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 7 Dec 2011 00:45:52 +0200 Subject: [PATCH] Speed-up symbolFiles:on operations on windows --- compiler/main.nim | 22 ++++++++++------------ compiler/rodread.nim | 4 ++-- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/compiler/main.nim b/compiler/main.nim index 944852bb68..fd29085168 100755 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -15,7 +15,8 @@ import os, lists, condsyms, rodread, rodwrite, ropes, trees, wordrecg, sem, semdata, idents, passes, docgen, extccomp, cgen, ecmasgen, - platform, nimconf, importer, passaux, depends, transf, evals, types, idgen + platform, nimconf, importer, passaux, depends, transf, evals, types, idgen, + tables const has_LLVM_Backend = false @@ -27,19 +28,16 @@ proc MainCommand*() # ------------------ module handling ----------------------------------------- -type - TFileModuleRec = tuple[filename: string, module: PSym] - TFileModuleMap = seq[TFileModuleRec] +var + compMods = initTable[string, PSym]() # all compiled modules -var compMods: TFileModuleMap = @[] # all compiled modules +# This expects a normalized module path +proc registerModule(filename: string, module: PSym) = + compMods[filename] = module -proc registerModule(filename: string, module: PSym) = - compMods.add((filename, module)) - -proc getModule(filename: string): PSym = - for i in countup(0, high(compMods)): - if sameFile(compMods[i].filename, filename): - return compMods[i].module +# This expects a normalized module path +proc getModule(filename: string): PSym = + result = compMods[filename] proc newModule(filename: string): PSym = # We cannot call ``newSym`` here, because we have to circumvent the ID diff --git a/compiler/rodread.nim b/compiler/rodread.nim index 2ab019c82b..9db083181f 100755 --- a/compiler/rodread.nim +++ b/compiler/rodread.nim @@ -788,7 +788,7 @@ proc loadMethods(r: PRodReader) = proc getModuleIdx(filename: string): int = for i in countup(0, high(gMods)): - if sameFile(gMods[i].filename, filename): return i + if gMods[i].filename == filename: return i result = len(gMods) setlen(gMods, result + 1) @@ -853,7 +853,7 @@ proc handleSymbolFile(module: PSym, filename: string): PRodReader = proc GetCRC*(filename: string): TCrc32 = for i in countup(0, high(gMods)): - if sameFile(gMods[i].filename, filename): return gMods[i].crc + if gMods[i].filename == filename: return gMods[i].crc result = crcFromFile(filename) #var idx = getModuleIdx(filename)