From 1e5ecbaa97e3ee864e8ec6e79df371ee83ff244c Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 11 May 2010 13:36:30 +0000 Subject: [PATCH] speedup of initial session file handling --- lib/core/target.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/core/target.py b/lib/core/target.py index 385a81fce..46255bc24 100644 --- a/lib/core/target.py +++ b/lib/core/target.py @@ -122,9 +122,10 @@ def __setOutputResume(): if os.path.exists(conf.sessionFile): if not conf.flushSession: readSessionFP = open(conf.sessionFile, "r") - lines = readSessionFP.readlines() + __url_cache = set() + __expression_cache = {} - for line in lines: + for line in readSessionFP.xreadlines(): if line.count("][") == 4: line = line.split("][") @@ -145,17 +146,20 @@ def __setOutputResume(): if url not in ( conf.url, conf.hostname ): continue - if url not in kb.resumedQueries.keys(): + if url not in __url_cache: kb.resumedQueries[url] = {} kb.resumedQueries[url][expression] = value + __url_cache.add(url) + __expression_cache[url] = set() resumeConfKb(expression, url, value) - if expression not in kb.resumedQueries[url].keys(): + if expression not in __expression_cache[url]: kb.resumedQueries[url][expression] = value + __expression_cache[url].add(value) elif len(value) >= len(kb.resumedQueries[url][expression]): kb.resumedQueries[url][expression] = value - + readSessionFP.close() else: try: