Mercurial > public > mercurial-scm > hg-stable
diff mercurial/wireproto.py @ 17557:6d97dd630d79
wireproto: bypass filechunkiter for small files when streaming
Merely creating and using a generator has a measurable impact,
particularly since the common case for stream_out is generators that
yield just once. Avoiding generators improves stream_out performance
by about 7%.
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Fri, 14 Sep 2012 12:05:37 -0700 |
parents | 39c6e349dfff |
children | 380a89413403 |
line wrap: on
line diff
--- a/mercurial/wireproto.py Fri Sep 14 12:05:12 2012 -0700 +++ b/mercurial/wireproto.py Fri Sep 14 12:05:37 2012 -0700 @@ -555,8 +555,11 @@ repo.ui.debug('sending %s (%d bytes)\n' % (name, size)) # partially encode name over the wire for backwards compat yield '%s\0%d\n' % (store.encodedir(name), size) - for chunk in util.filechunkiter(sopener(name), limit=size): - yield chunk + if size <= 65536: + yield sopener(name).read(size) + else: + for chunk in util.filechunkiter(sopener(name), limit=size): + yield chunk finally: sopener.mustaudit = oldaudit