transforms.llvm_ir_generator: fix memoize().

This commit is contained in:
whitequark 2016-01-16 00:38:57 +00:00
parent e6185e16d8
commit 85222783ee

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