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 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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue