Mercurial > public > mercurial-scm > hg-stable
diff mercurial/sshpeer.py @ 36657:70415568ea65
sshpeer: don't read(0)
read(0) is essentially a no-op. Let's avoid the function call, overhead,
and extra test output by not performing it.
Differential Revision: https://phab.mercurial-scm.org/D2581
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 02 Mar 2018 22:59:12 -0500 |
parents | 1151c731686e |
children | 46f4d71ed505 |
line wrap: on
line diff
--- a/mercurial/sshpeer.py Sat Mar 03 05:51:34 2018 -0500 +++ b/mercurial/sshpeer.py Fri Mar 02 22:59:12 2018 -0500 @@ -523,7 +523,11 @@ self._abort(error.ResponseError(_("unexpected response:"), l)) def _readframed(self): - return self._pipei.read(self._getamount()) + size = self._getamount() + if not size: + return b'' + + return self._pipei.read(size) def _writeframed(self, data, flush=False): self._pipeo.write("%d\n" % len(data))