diff options
Diffstat (limited to 'pack-objects.h')
| -rw-r--r-- | pack-objects.h | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/pack-objects.h b/pack-objects.h index 3f6f504203..83299d4732 100644 --- a/pack-objects.h +++ b/pack-objects.h @@ -1,9 +1,10 @@ #ifndef PACK_OBJECTS_H #define PACK_OBJECTS_H -#include "object-store-ll.h" +#include "odb.h" #include "thread-utils.h" #include "pack.h" +#include "packfile.h" struct repository; @@ -119,11 +120,23 @@ struct object_entry { unsigned ext_base:1; /* delta_idx points outside packlist */ }; +/** + * A packing region is a section of the packing_data.objects array + * as given by a starting index and a number of elements. + */ +struct packing_region { + size_t start; + size_t nr; +}; + struct packing_data { struct repository *repo; struct object_entry *objects; uint32_t nr_objects, nr_alloc; + struct packing_region *regions; + size_t nr_regions, nr_regions_alloc; + int32_t *index; uint32_t index_size; @@ -208,6 +221,34 @@ static inline uint32_t pack_name_hash(const char *name) return hash; } +static inline uint32_t pack_name_hash_v2(const unsigned char *name) +{ + uint32_t hash = 0, base = 0, c; + + if (!name) + return 0; + + while ((c = *name++)) { + if (isspace(c)) + continue; + if (c == '/') { + base = (base >> 6) ^ hash; + hash = 0; + } else { + /* + * 'c' is only a single byte. Reverse it and move + * it to the top of the hash, moving the rest to + * less-significant bits. + */ + c = (c & 0xF0) >> 4 | (c & 0x0F) << 4; + c = (c & 0xCC) >> 2 | (c & 0x33) << 2; + c = (c & 0xAA) >> 1 | (c & 0x55) << 1; + hash = (hash >> 2) + (c << 24); + } + } + return (base >> 6) ^ hash; +} + static inline enum object_type oe_type(const struct object_entry *e) { return e->type_valid ? e->type_ : OBJ_BAD; |
