forked from M-Labs/artiq
transforms.llvm_ir_generator: fix memoize().
This commit is contained in:
parent
e6185e16d8
commit
85222783ee
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue