If our current buffer is empty, there's no need to cat_bytes()
it with the new buffer, we can just replace the empty one with
the new one. This saves the memcpy() in many cases. Especially
if the whole file was read in one chunk (by bumping up the read
size) this saves a lot of time.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
self.start = 0
def put(self, s):
- if s:
+ if not self.data:
+ self.data = s
+ self.start = 0
+ elif s:
remaining = len(self.data) - self.start
self.data = cat_bytes(self.data, self.start, remaining,
s, 0, len(s))