sha1_file: add raw_object_store argument to alt_odb_usable
[gitweb.git] / pack-revindex.c
index 96d51c3467b9ef864f62962aa3567247338d2c3a..bb521cf7fb2911bc2d3653f46224880f8540f9ab 100644 (file)
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "pack-revindex.h"
+#include "object-store.h"
 
 /*
  * Pack index for existing packs give us easy access to the offsets into
@@ -59,7 +60,6 @@ static void sort_revindex(struct revindex_entry *entries, unsigned n, off_t max)
         * be a no-op, as everybody lands in the same zero-th bucket.
         */
        for (bits = 0; max >> bits; bits += DIGIT_SIZE) {
-               struct revindex_entry *swap;
                unsigned i;
 
                memset(pos, 0, BUCKETS * sizeof(*pos));
@@ -97,9 +97,7 @@ static void sort_revindex(struct revindex_entry *entries, unsigned n, off_t max)
                 * Now "to" contains the most sorted list, so we swap "from" and
                 * "to" for the next iteration.
                 */
-               swap = from;
-               from = to;
-               to = swap;
+               SWAP(from, to);
        }
 
        /*
@@ -107,7 +105,7 @@ static void sort_revindex(struct revindex_entry *entries, unsigned n, off_t max)
         * we have to move it back from the temporary storage.
         */
        if (from != entries)
-               memcpy(entries, tmp, n * sizeof(*entries));
+               COPY_ARRAY(entries, tmp, n);
        free(tmp);
        free(pos);
 
@@ -137,10 +135,8 @@ static void create_pack_revindex(struct packed_git *p)
                        if (!(off & 0x80000000)) {
                                p->revindex[i].offset = off;
                        } else {
-                               p->revindex[i].offset =
-                                       ((uint64_t)ntohl(*off_64++)) << 32;
-                               p->revindex[i].offset |=
-                                       ntohl(*off_64++);
+                               p->revindex[i].offset = get_be64(off_64);
+                               off_64 += 2;
                        }
                        p->revindex[i].nr = i;
                }