From patchwork Fri Mar 31 04:45:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [9,of,9,V2] revlog: add a fast path for revision(raw=False) From: Jun Wu X-Patchwork-Id: 19861 Message-Id: <70c6b2eecf4d580d3840.1490935518@x1c> To: Date: Thu, 30 Mar 2017 21:45:18 -0700 # HG changeset patch # User Jun Wu # Date 1490934075 25200 # Thu Mar 30 21:21:15 2017 -0700 # Node ID 70c6b2eecf4d580d38404f157ef99da237593a68 # Parent 3a4dd24ccf078c47722582f00872a88d33042ac3 # Available At https://bitbucket.org/quark-zju/hg-draft # hg pull https://bitbucket.org/quark-zju/hg-draft -r 70c6b2eecf4d revlog: add a fast path for revision(raw=False) If cache hit and flags are empty, no flag processor runs and "text" equals to "rawtext". So we check flags, and return rawtext. This resolves performance issue introduced by a previous patch. diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -1275,4 +1275,11 @@ class revlog(object): if raw: return self._cache[2] + # duplicated, but good for perf + if rev is None: + rev = self.rev(node) + # no extra flags set, no flag processor runs, text = rawtext + if self.flags(rev) == REVIDX_DEFAULT_FLAGS: + return self._cache[2] + cachedrev = self._cache[1]