From 85222783ee0df567ddfa35ac6bafde545de6799c Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 16 Jan 2016 00:38:57 +0000 Subject: [PATCH] transforms.llvm_ir_generator: fix memoize(). --- artiq/compiler/transforms/llvm_ir_generator.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/artiq/compiler/transforms/llvm_ir_generator.py b/artiq/compiler/transforms/llvm_ir_generator.py index 940240b39..eb8c1e1f1 100644 --- a/artiq/compiler/transforms/llvm_ir_generator.py +++ b/artiq/compiler/transforms/llvm_ir_generator.py @@ -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