# HG changeset patch # User Gregory Szorc # Date 1457298834 28800 # Node ID 63653147e9bb26550cbe46d5a1bdf961471af0e5 # Parent 7796473c11b3b0c132bea567a4660626cb57fdb2 changelog: parse description last Before, we first searched for the double newline as the first step in the parse then moved to the front of the string and worked our way to the back again. This made sense when we were splitting the raw text on the double newline. But in our new newline scanning based approach, this feels awkward. This patch updates the parsing logic to parse the text linearly and deal with the description field last. Because we're avoiding an extra string scan, revsets appear to demonstrate a very slight performance win. But the percentage change is marginal, so the numbers aren't worth reporting. diff -r 7796473c11b3 -r 63653147e9bb mercurial/changelog.py --- a/mercurial/changelog.py Sun Mar 06 14:31:06 2016 -0800 +++ b/mercurial/changelog.py Sun Mar 06 13:13:54 2016 -0800 @@ -184,9 +184,6 @@ # # changelog v0 doesn't use extra - doublenl = text.index('\n\n') - self._rawdesc = text[doublenl + 2:] - nl1 = text.index('\n') self._rawmanifest = text[0:nl1] @@ -198,10 +195,13 @@ # The list of files may be empty. Which means nl3 is the first of the # double newline that precedes the description. - if nl3 == doublenl: + if text[nl3 + 1] == '\n': self._rawfiles = None + self._rawdesc = text[nl3 + 2:] else: + doublenl = text.index('\n\n', nl3 + 1) self._rawfiles = text[nl3 + 1:doublenl] + self._rawdesc = text[doublenl + 2:] return self