Mercurial > public > mercurial-scm > hg
diff mercurial/pure/bdiff.py @ 28389:9ab45fbe045e stable
bdiff: (pure) support array.array arrays (issue5130)
author | timeless <timeless@mozdev.org> |
---|---|
date | Tue, 08 Mar 2016 17:26:12 +0000 |
parents | c4e3ff497f89 |
children | a8933d992a71 |
line wrap: on
line diff
--- a/mercurial/pure/bdiff.py Wed Mar 09 22:21:08 2016 +0000 +++ b/mercurial/pure/bdiff.py Tue Mar 08 17:26:12 2016 +0000 @@ -7,6 +7,7 @@ from __future__ import absolute_import +import array import difflib import re import struct @@ -50,9 +51,15 @@ r.append(prev) return r +def _tostring(c): + if type(c) is array.array: + # this copy overhead isn't ideal + return c.tostring() + return str(c) + def bdiff(a, b): - a = str(a).splitlines(True) - b = str(b).splitlines(True) + a = _tostring(a).splitlines(True) + b = _tostring(b).splitlines(True) if not a: s = "".join(b)