Skip to content

Commit ee78052

Browse files
author
Kim Gustyr
committed
make buffers faster
1 parent 0261aa5 commit ee78052

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

snappy/snappy.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ def add_chunk(self, data, compress=None):
130130
out = bytearray()
131131
if not self._header_chunk_written:
132132
self._header_chunk_written = True
133-
out += struct.pack("<L", _IDENTIFIER_CHUNK +
134-
(len(_STREAM_IDENTIFIER) << 8))
135-
out += _STREAM_IDENTIFIER
133+
out.extend(struct.pack("<L", _IDENTIFIER_CHUNK +
134+
(len(_STREAM_IDENTIFIER) << 8)))
135+
out.extend(_STREAM_IDENTIFIER)
136136
for i in range(0, len(data), _CHUNK_MAX):
137137
chunk = data[i:i + _CHUNK_MAX]
138138
crc = _masked_crc32c(chunk)
@@ -150,9 +150,9 @@ def add_chunk(self, data, compress=None):
150150
chunk_type = _COMPRESSED_CHUNK
151151
else:
152152
chunk_type = _UNCOMPRESSED_CHUNK
153-
out += struct.pack("<LL", chunk_type + ((len(chunk) + 4) << 8),
154-
crc)
155-
out += chunk
153+
out.extend(struct.pack("<LL", chunk_type + ((len(chunk) + 4) << 8),
154+
crc))
155+
out.extend(chunk)
156156
return bytes(out)
157157

158158
def compress(self, data):
@@ -221,7 +221,7 @@ def decompress(self, data):
221221
the decompress() method. Some of the input data may be preserved in
222222
internal buffers for later processing.
223223
"""
224-
self._buf += data
224+
self._buf.extend(data)
225225
uncompressed = bytearray()
226226
while True:
227227
if len(self._buf) < 4:

0 commit comments

Comments
 (0)