Rev 3902: Simplify the code a bit. We don't repack as often, so go with a in http://bzr.arbash-meinel.com/branches/bzr/brisbane/gc_delta_index_room
John Arbash Meinel
john at arbash-meinel.com
Thu Mar 19 06:15:55 GMT 2009
At http://bzr.arbash-meinel.com/branches/bzr/brisbane/gc_delta_index_room
------------------------------------------------------------
revno: 3902
revision-id: john at arbash-meinel.com-20090319061549-fzk7na4uczpev2iy
parent: john at arbash-meinel.com-20090319061002-bcf6ikop39ap4s6w
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: gc_delta_index_room
timestamp: Thu 2009-03-19 01:15:49 -0500
message:
Simplify the code a bit. We don't repack as often, so go with a
more obvious code, rather than trying tricks with memcpy()
(it didn't seem to really help, anyway).
-------------- next part --------------
=== modified file 'bzrlib/diff-delta.c'
--- a/bzrlib/diff-delta.c 2009-03-19 06:10:02 +0000
+++ b/bzrlib/diff-delta.c 2009-03-19 06:15:49 +0000
@@ -212,7 +212,7 @@
pack_delta_index(struct unpacked_index_entry **hash, unsigned int hsize,
unsigned int num_entries, struct delta_index *old_index)
{
- unsigned int i, j, hmask, memsize, to_copy, fit_in_old, copied_count;
+ unsigned int i, j, hmask, memsize, fit_in_old, copied_count;
struct unpacked_index_entry *entry;
struct delta_index *index;
struct index_entry *packed_entry, **packed_hash, *old_entry, *copy_from;
@@ -275,6 +275,7 @@
if (fit_in_old) {
fprintf(stderr, "Fit all %d entries into old index\n",
copied_count);
+ /* No need to allocate a new buffer */
return NULL;
} else {
fprintf(stderr, "Fit only %d entries into old index,"
@@ -322,36 +323,22 @@
*/
j = i & old_index->hash_mask;
copy_from = old_index->hash[j];
- to_copy = 0;
for (old_entry = old_index->hash[j];
old_entry < old_index->hash[j + 1] && old_entry->ptr != NULL;
old_entry++) {
if ((old_entry->val & hmask) == i) {
- to_copy += 1;
- } else {
- /* We reached the end of a string of entries that should
- * be copied. Copy the group, and then move the pointers.
- */
- if (to_copy > 0) {
- memcpy(packed_entry, copy_from,
- sizeof(*old_entry)*to_copy);
- packed_entry += to_copy;
- to_copy = 0;
- }
- /* Don't copy *this* entry, and start the copy after this */
- copy_from = old_entry + 1;
+ *packed_entry++ = *old_entry;
}
}
- if (to_copy > 0) {
- memcpy(packed_entry, copy_from,
- sizeof(*old_entry)*to_copy);
- packed_entry += to_copy;
- to_copy = 0;
- }
}
for (entry = hash[i]; entry; entry = entry->next) {
*packed_entry++ = entry->entry;
}
+ /* TODO: At this point packed_entry - packed_hash[i] is the number of
+ * records that we have inserted into this hash bucket.
+ * We should *really* consider doing some limiting along the
+ * lines of limit_hash_buckets() to avoid pathological behavior.
+ */
/* Now add extra 'NULL' entries that we can use for future expansion. */
for (j = 0; j < EXTRA_NULLS; ++j ) {
*packed_entry++ = null_entry;
More information about the bazaar-commits
mailing list