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 memoize(generator):
def memoized(self, *args): def memoized(self, *args):
result = self.cache.get((generator,) + args, None) key = (generator,) + args
if result is None: try:
return generator(self, *args) return self.cache[key]
else: except KeyError:
result = generator(self, *args)
self.cache[key] = result
return result return result
return memoized return memoized