Re: [PATCH 2/2] Cached the git configuration, which is now noticibly faster on windows.
- From
David Symonds <dsymonds@gmail.com>
- Date
- Nov 8, 2008, 05:19 UTC
- Message-ID
- <ee77f5c20811072119y65738f54o7e6792fb405c142c@mail.gmail.com>
- In-Reply-To
- <1226114569-8506-2-git-send-email-thestar@fussycoder.id.au>
On Fri, Nov 7, 2008 at 7:22 PM, John Chapman <thestar@fussycoder.id.au> wrote:
Show 6 quoted lines
> +_gitConfig = {}
> def gitConfig(key):
> - return read_pipe("git config %s" % key, ignore_error=True).strip()
> + if not _gitConfig.has_key(key):
> + _gitConfig[key] = read_pipe("git config %s" % key, ignore_error=True).strip()
> + return _gitConfig[key]If this is truly a noticeable bottleneck on Windows, something like the following might be even better: (completely untested!)
_gitConfig = None
def gitConfig(key):
if _gitConfig is None:
lines = read_pipe("git config -l", ignore_error=True).readlines():
_gitConfig = dict([l.strip().split('=', 1) for l in lines])
return _gitConfig.get(key, None)Dave.