# HG changeset patch # User Gregory Szorc # Date 2015-12-21 00:00:27 # Node ID a2e2a8fa5fd1193f83d76c303d7bb81cb2c56685 # Parent e517a89c24e11b376b1fc585f999dd0f9722361a revlog: avoid string slice when decompressing u* chunks Revlog chunks can be stored uncompressed. If the first byte of the raw data is \0, we store the data as is. Else we prefix it with 'u'. Before, we performed a string slice to strip out the 'u' prefix. With this patch, we use a buffer to avoid an extra memory copy and associated garbage collection overhead. I was unable to verify any performance impact of this patch. For both mozilla-central and the hg repos, the number of manifest revisions with 'u' prefixes is very small - under 1%. So this change likely isn't called enough to have an impact on manifest reading. However, the reasoning behind this change is solid, so it should be safe. diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -110,7 +110,7 @@ def decompress(bin): except zlib.error as e: raise RevlogError(_("revlog decompress error: %s") % str(e)) if t == 'u': - return bin[1:] + return util.buffer(bin, 1) raise RevlogError(_("unknown compression type %r") % t) # index v0: