forked from M-Labs/artiq
1
0
Fork 0

transforms.llvm_ir_generator: fix memoize().

This commit is contained in:
whitequark 2016-01-16 00:38:57 +00:00
parent e6185e16d8
commit 85222783ee
1 changed files with 6 additions and 4 deletions

View File

@ -29,10 +29,12 @@ DW_TAG_subprogram = 46
def memoize(generator):
def memoized(self, *args):
result = self.cache.get((generator,) + args, None)
if result is None:
return generator(self, *args)
else:
key = (generator,) + args
try:
return self.cache[key]
except KeyError:
result = generator(self, *args)
self.cache[key] = result
return result
return memoized