diff options
author | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-02-09 13:34:28 -0500 |
---|---|---|
committer | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-02-09 13:34:28 -0500 |
commit | f983b9d17737533225da4b1ec851c421c13af9e8 (patch) | |
tree | e9df7600965b5ae34a2d8d48f282a8d2bba59da1 /tools/shared.py | |
parent | 96dfd8be059f1657e217177a9cc3cbe5e8d9aa46 (diff) |
Cache the result of is_ar
Diffstat (limited to 'tools/shared.py')
-rw-r--r-- | tools/shared.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/shared.py b/tools/shared.py index 56a404fb..2ee855d9 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -733,14 +733,19 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)'''.replace('$EMSCRIPTEN_ROOT', path_ return filename + '.cc.js' + _is_ar_cache = {} @staticmethod def is_ar(filename): try: + if Building._is_ar_cache.get(filename): + return Building._is_ar_cache[filename] b = open(filename, 'r').read(8) - return b[0] == '!' and b[1] == '<' and \ - b[2] == 'a' and b[3] == 'r' and \ - b[4] == 'c' and b[5] == 'h' and \ - b[6] == '>' and ord(b[7]) == 10 + sigcheck = b[0] == '!' and b[1] == '<' and \ + b[2] == 'a' and b[3] == 'r' and \ + b[4] == 'c' and b[5] == 'h' and \ + b[6] == '>' and ord(b[7]) == 10 + Building._is_ar_cache[filename] = sigcheck + return sigcheck except: return False |