optimization

This commit is contained in:
Thomas Nagy 2012-09-02 19:55:54 +02:00
parent 220c438320
commit b5c043ef49
1 changed files with 5 additions and 8 deletions

View File

@ -99,7 +99,7 @@ class Node(object):
The Node objects are not thread safe in any way.
"""
__slots__ = ('name', 'sig', 'children', 'parent', 'cache_abspath', 'cache_isdir')
__slots__ = ('name', 'sig', 'children', 'parent', 'cache_abspath', 'cache_isdir', 'cache_sig')
def __init__(self, name, parent):
self.name = name
self.parent = parent
@ -788,19 +788,16 @@ class Node(object):
Node signature, assuming the file is in the build directory
"""
try:
ret = self.ctx.hash_cache[id(self)]
except KeyError:
pass
return self.cache_sig
except AttributeError:
self.ctx.hash_cache = {}
else:
return ret
pass
if not self.is_bld() or self.ctx.bldnode is self.ctx.srcnode:
self.sig = Utils.h_file(self.abspath())
self.ctx.hash_cache[id(self)] = ret = self.sig
self.cache_sig = ret = self.sig
return ret
# TODO Waf 1.8
search = search_node