summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-10-18 21:12:42 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-10-18 21:12:42 +0200
commitca829e0b341dd5c3ae1408b24702f2c75db6ec73 (patch)
tree26827ebd27a107f927aff352df47b1621eee13cf
parent81a96250f1758844a1c95f0293083c18c4ce98dc (diff)
downloadgitdb-ca829e0b341dd5c3ae1408b24702f2c75db6ec73.tar.gz
now byte-copying a few chunks where possible when slicing, which gives a few percent of performance
-rw-r--r--_delta_apply.c20
-rw-r--r--stream.py2
2 files changed, 10 insertions, 12 deletions
diff --git a/_delta_apply.c b/_delta_apply.c
index 068d89a..e99a803 100644
--- a/_delta_apply.c
+++ b/_delta_apply.c
@@ -534,13 +534,12 @@ uint DIV_count_slice_bytes(const DeltaInfoVector* src, uint ofs, uint size)
}
const DeltaInfo const* vecend = DIV_end(src);
+ const uchar* nstream;
for( ;cdi < vecend; ++cdi){
- next_delta_info(src->dstream + cdi->dso, &dc);
+ nstream = next_delta_info(src->dstream + cdi->dso, &dc);
if (dc.ts < size) {
- // TODO: could just count size of the delta chunk in the stream instead
- // of reencoding
- num_bytes += DC_count_encode_bytes(&dc);
+ num_bytes += nstream - (src->dstream + cdi->dso);
size -= dc.ts;
} else {
dc.ts = size;
@@ -589,16 +588,15 @@ uint DIV_copy_slice_to(const DeltaInfoVector* src, uchar** dest, ull tofs, uint
}
}
- const DeltaInfo* vecend = DIV_end(src);
- for( ;cdi < vecend; ++cdi)
+ const uchar* dstream = src->dstream + cdi->dso;
+ const uchar* nstream = dstream;
+ for( ; nstream; dstream = nstream)
{
num_chunks += 1;
- next_delta_info(src->dstream + cdi->dso, &dc);
+ nstream = next_delta_info(dstream, &dc);
if (dc.ts < size) {
- // Full copy would be possible, but the final length of the dstream
- // needs to be used as well to know how many bytes to copy
- // TODO: make a DIV_ function for this
- DC_encode_to(&dc, dest, 0, dc.ts);
+ memcpy(*dest, dstream, nstream - dstream);
+ *dest += nstream - dstream;
size -= dc.ts;
} else {
DC_encode_to(&dc, dest, 0, size);
diff --git a/stream.py b/stream.py
index 0d89728..f522bd3 100644
--- a/stream.py
+++ b/stream.py
@@ -445,7 +445,7 @@ class DeltaApplyReader(LazyMixin):
#{ Configuration
- if not has_perf_mod:
+ if has_perf_mod:
_set_cache_ = _set_cache_brute_
else:
_set_cache_ = _set_cache_too_slow_without_c