From 68b50bd7328dc3fc7f9826d2f261e3a9116e5be9 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sat, 9 Mar 2013 21:20:58 +0200 Subject: [PATCH] Cache external programs in coredata. --- coredata.py | 9 ++------- interpreter.py | 4 ++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/coredata.py b/coredata.py index 2ed8a263e..3024dda99 100644 --- a/coredata.py +++ b/coredata.py @@ -37,14 +37,9 @@ class CoreData(): self.strip = options.strip self.coverage = options.coverage + self.compilers = {} self.deps = {} - # To prevent weird bugs, compiler name can not be altered - # after it is first declared. So always copy all compilers - # from old coredata. - if isinstance(options, CoreData): - self.compilers = options.compilers.copy() - else: - self.compilers = {} + self.ext_progs = {} def load(filename): obj = pickle.load(open(filename, 'rb')) diff --git a/interpreter.py b/interpreter.py index 94b1c5cc0..1191d5924 100755 --- a/interpreter.py +++ b/interpreter.py @@ -615,8 +615,12 @@ class Interpreter(): if not isinstance(required, bool): raise InvalidArguments('Line %d: "required" argument must be a boolean.' % node.lineno()) exename = args[0] + if exename in self.coredata.ext_progs and\ + self.coredata.ext_progs[exename].found(): + return self.coredata.ext_progs[exename] result = shutil.which(exename) # Does .exe appending on Windows. progobj = ExternalProgram(exename, result) + self.coredata.ext_progs[exename] = progobj if required and not progobj.found(): raise InvalidArguments('Line %d: program "%s" not found.' % (node.lineno(), exename)) return progobj