mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-11 01:41:57 -04:00
buzhash/buzhash64: initialise all-zero memory more efficiently
This commit is contained in:
parent
631ef99e3f
commit
870f414690
2 changed files with 6 additions and 6 deletions
|
|
@ -7,7 +7,7 @@ import time
|
|||
from cpython.bytes cimport PyBytes_AsString
|
||||
from libc.stdint cimport uint8_t, uint32_t
|
||||
from libc.stdlib cimport malloc, free
|
||||
from libc.string cimport memcpy, memmove
|
||||
from libc.string cimport memcpy, memmove, memset
|
||||
|
||||
from ..constants import CH_DATA, CH_ALLOC, CH_HOLE, zeros
|
||||
from .reader import FileReader, Chunk
|
||||
|
|
@ -199,8 +199,8 @@ cdef class Chunker:
|
|||
# Copy data from chunk to our buffer
|
||||
memcpy(self.data + self.position + self.remaining, <const unsigned char*>PyBytes_AsString(chunk.data), n)
|
||||
else:
|
||||
# For holes, fill with zeros
|
||||
memcpy(self.data + self.position + self.remaining, <const unsigned char*>PyBytes_AsString(zeros[:n]), n)
|
||||
# For holes, fill with zeros using memset
|
||||
memset(self.data + self.position + self.remaining, 0, n)
|
||||
|
||||
self.remaining += n
|
||||
self.bytes_read += n
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import time
|
|||
from cpython.bytes cimport PyBytes_AsString
|
||||
from libc.stdint cimport uint8_t, uint64_t
|
||||
from libc.stdlib cimport malloc, free
|
||||
from libc.string cimport memcpy, memmove
|
||||
from libc.string cimport memcpy, memmove, memset
|
||||
|
||||
from ..crypto.low_level import CSPRNG
|
||||
|
||||
|
|
@ -176,8 +176,8 @@ cdef class ChunkerBuzHash64:
|
|||
# Copy data from chunk to our buffer
|
||||
memcpy(self.data + self.position + self.remaining, <const unsigned char*>PyBytes_AsString(chunk.data), n)
|
||||
else:
|
||||
# For holes, fill with zeros
|
||||
memcpy(self.data + self.position + self.remaining, <const unsigned char*>PyBytes_AsString(zeros[:n]), n)
|
||||
# For holes, fill with zeros using memset
|
||||
memset(self.data + self.position + self.remaining, 0, n)
|
||||
|
||||
self.remaining += n
|
||||
self.bytes_read += n
|
||||
|
|
|
|||
Loading…
Reference in a new issue