From: cournape Date: Thu, 19 Nov 2009 05:38:09 +0000 (+0000) Subject: ENH: add a cache for get_installed_vcs, as it used for every MS tool exists function... X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d59c7325e8f93b283da077fba5445c80ba4dfada;p=scons.git ENH: add a cache for get_installed_vcs, as it used for every MS tool exists function and is expensive. git-svn-id: http://scons.tigris.org/svn/scons/trunk@4462 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index 62f1aa97..108b781e 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -173,6 +173,16 @@ def find_batch_file(msvc_version): debug("Not found: %s" % batfilename) return None +__INSTALLED_VCS_RUN = None + +def cached_get_installed_vcs(): + global __INSTALLED_VCS_RUN + + if __INSTALLED_VCS_RUN is None: + ret = get_installed_vcs() + __INSTALLED_VCS_RUN = ret + + return __INSTALLED_VCS_RUN def get_installed_vcs(): installed_versions = [] @@ -219,7 +229,7 @@ def get_default_version(env): % (msvc_version, msvs_version)) return msvs_version if not msvc_version: - installed_vcs = get_installed_vcs() + installed_vcs = cached_get_installed_vcs() debug('installed_vcs:%s' % installed_vcs) if not installed_vcs: msg = 'No installed VCs' @@ -267,7 +277,7 @@ def msvc_setup_env(env): debug('Caught exception while looking for batch file (%s)' % msg) warn_msg = "VC version %s not installed - C/C++ compilers most " \ "likely not set correctly" % version - warn_msg += " \n Install versions are: %s" % get_installed_vcs() + warn_msg += " \n Install versions are: %s" % cached_get_installed_vcs() SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) return None @@ -296,7 +306,7 @@ def msvc_setup_env(env): env.PrependENVPath(k, v, delete_existing=True) def msvc_exists(version=None): - vcs = get_installed_vcs() + vcs = cached_get_installed_vcs() if version is None: return len(vcs) > 0 return version in vcs