[PATCH 07 of 10] bytearray: replace array.array with bytearray
timeless
timeless at gmail.com
Wed May 18 15:03:06 EDT 2016
On Wed, May 18, 2016 at 12:08 PM, Martijn Pieters <mj at zopatista.com> wrote:
> Just pass in the integer result:
> self._rbcrevs = bytearray(self._rbcrevslen * _rbcrecsize)
> This produces a bytearray of that size, filled with null bytes.
will do
> Would starting chunks as a bytearray, then extending *that* instead of
> a list, not work better? That would avoid creating a series of
> intermediate strings here.
>
> chunks = bytearray()
>
> for node in outgoing.missingheads:
> # Don't compute missing, as this may slow down serving.
> fnode = cache.getfnode(node, computemissing=False)
> if fnode is not None:
> chunks += node
> chunks += fnode
>
> Now you have just one bytestring object to convert to str.
It definitely works. I'll include it with a v2.
>> - deltatext = mdiff.textdiff(base, arraytext)
>> + arraytext = bytearray(self.text())
>> + deltatext = mdiff.textdiff(str(base), str(arraytext))
>>
>> return arraytext, deltatext
>
> If self.text() is a string already, why convert to a bytearray then
> back to str?
I'll add a comment. The short answer is that mdiff.textdiff (~ bdiff)
currently takes a string,
but it shouldn't. It should take a bytearray.
The goal of this commit is to get rid of array.array. In a separate
commit, I'll convert bdiff to
accept bytearrays.
>> @@ -430,13 +427,12 @@
>> try:
>> data = repo.vfs.read(_fnodescachefile)
>> except (OSError, IOError):
>> data = ""
>> - self._raw.fromstring(data)
>> + data = repo.vfs.tryread(_fnodescachefile)
>> + self._raw = bytearray(data)
>
> data is set twice now; you didn't remove the try..except.
Oops. That was a mis-merge. I didn't check the history when I did the merge.
I'll remove the first insertion.
More information about the Mercurial-devel
mailing list