Skip to content

Commit

Permalink
tiny optimization to diff-delta
Browse files Browse the repository at this point in the history
This is my assembly freak side looking at generated code again.  And
since create_delta() is certainly pretty high on the radar every bits
count.  In this case shorter code is generated if hash_mask is not
copied to a local variable.

Signed-off-by: Nicolas Pitre <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Nicolas Pitre authored and Junio C Hamano committed May 3, 2006
1 parent 3dc5a9e commit 2d08e5d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions diff-delta.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ create_delta(const struct delta_index *index,
const void *trg_buf, unsigned long trg_size,
unsigned long *delta_size, unsigned long max_size)
{
unsigned int i, outpos, outsize, hash_mask, val;
unsigned int i, outpos, outsize, val;
int inscnt;
const unsigned char *ref_data, *ref_top, *data, *top;
unsigned char *out;
Expand Down Expand Up @@ -275,7 +275,6 @@ create_delta(const struct delta_index *index,
ref_top = ref_data + index->src_size;
data = trg_buf;
top = trg_buf + trg_size;
hash_mask = index->hash_mask;

outpos++;
val = 0;
Expand All @@ -290,7 +289,7 @@ create_delta(const struct delta_index *index,
struct index_entry *entry;
val ^= U[data[-RABIN_WINDOW]];
val = ((val << 8) | *data) ^ T[val >> RABIN_SHIFT];
i = val & hash_mask;
i = val & index->hash_mask;
for (entry = index->hash[i]; entry; entry = entry->next) {
const unsigned char *ref = entry->ptr;
const unsigned char *src = data;
Expand Down

0 comments on commit 2d08e5d

Please sign in to comment.