From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 1/2] index-pack: rename the field "type" to "in_pack_type"
Date: Wed, 8 Jul 2015 18:56:30 +0700 [thread overview]
Message-ID: <1436356591-8148-1-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <20150707160630.GA4456@peff.net>
We have two types in this code: in-pack and canonical. "in_pack_type"
makes it clearer than plain "type".
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/index-pack.c | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 48fa472..797e571 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -19,7 +19,7 @@ struct object_entry {
struct pack_idx_entry idx;
unsigned long size;
unsigned char hdr_size;
- signed char type;
+ signed char in_pack_type;
signed char real_type;
};
@@ -493,7 +493,7 @@ static void *unpack_raw_entry(struct object_entry *obj,
p = fill(1);
c = *p;
use(1);
- obj->type = (c >> 4) & 7;
+ obj->in_pack_type = (c >> 4) & 7;
size = (c & 15);
shift = 4;
while (c & 0x80) {
@@ -505,7 +505,7 @@ static void *unpack_raw_entry(struct object_entry *obj,
}
obj->size = size;
- switch (obj->type) {
+ switch (obj->in_pack_type) {
case OBJ_REF_DELTA:
hashcpy(ref_sha1, fill(20));
use(20);
@@ -534,11 +534,11 @@ static void *unpack_raw_entry(struct object_entry *obj,
case OBJ_TAG:
break;
default:
- bad_object(obj->idx.offset, _("unknown object type %d"), obj->type);
+ bad_object(obj->idx.offset, _("unknown object type %d"), obj->in_pack_type);
}
obj->hdr_size = consumed_bytes - obj->idx.offset;
- data = unpack_entry_data(obj->idx.offset, obj->size, obj->type, sha1);
+ data = unpack_entry_data(obj->idx.offset, obj->size, obj->in_pack_type, sha1);
obj->idx.crc32 = input_crc32;
return data;
}
@@ -631,7 +631,7 @@ static int find_ofs_delta(const off_t offset, enum object_type type)
int cmp;
cmp = compare_ofs_delta_bases(offset, delta->offset,
- type, objects[delta->obj_no].type);
+ type, objects[delta->obj_no].in_pack_type);
if (!cmp)
return next;
if (cmp < 0) {
@@ -685,7 +685,7 @@ static int find_ref_delta(const unsigned char *sha1, enum object_type type)
int cmp;
cmp = compare_ref_delta_bases(sha1, delta->sha1,
- type, objects[delta->obj_no].type);
+ type, objects[delta->obj_no].in_pack_type);
if (!cmp)
return next;
if (cmp < 0) {
@@ -759,7 +759,7 @@ static int check_collison(struct object_entry *entry)
enum object_type type;
unsigned long size;
- if (entry->size <= big_file_threshold || entry->type != OBJ_BLOB)
+ if (entry->size <= big_file_threshold || entry->in_pack_type != OBJ_BLOB)
return -1;
memset(&data, 0, sizeof(data));
@@ -767,7 +767,7 @@ static int check_collison(struct object_entry *entry)
data.st = open_istream(entry->idx.sha1, &type, &size, NULL);
if (!data.st)
return -1;
- if (size != entry->size || type != entry->type)
+ if (size != entry->size || type != entry->in_pack_type)
die(_("SHA1 COLLISION FOUND WITH %s !"),
sha1_to_hex(entry->idx.sha1));
unpack_data(entry, compare_objects, &data);
@@ -891,7 +891,7 @@ static void *get_base_data(struct base_data *c)
struct base_data **delta = NULL;
int delta_nr = 0, delta_alloc = 0;
- while (is_delta_type(c->obj->type) && !c->data) {
+ while (is_delta_type(c->obj->in_pack_type) && !c->data) {
ALLOC_GROW(delta, delta_nr + 1, delta_alloc);
delta[delta_nr++] = c;
c = c->base;
@@ -1085,7 +1085,7 @@ static void *threaded_second_pass(void *data)
counter_unlock();
work_lock();
while (nr_dispatched < nr_objects &&
- is_delta_type(objects[nr_dispatched].type))
+ is_delta_type(objects[nr_dispatched].in_pack_type))
nr_dispatched++;
if (nr_dispatched >= nr_objects) {
work_unlock();
@@ -1121,12 +1121,12 @@ static void parse_pack_objects(unsigned char *sha1)
struct object_entry *obj = &objects[i];
void *data = unpack_raw_entry(obj, &ofs_delta->offset,
ref_delta_sha1, obj->idx.sha1);
- obj->real_type = obj->type;
- if (obj->type == OBJ_OFS_DELTA) {
+ obj->real_type = obj->in_pack_type;
+ if (obj->in_pack_type == OBJ_OFS_DELTA) {
nr_ofs_deltas++;
ofs_delta->obj_no = i;
ofs_delta++;
- } else if (obj->type == OBJ_REF_DELTA) {
+ } else if (obj->in_pack_type == OBJ_REF_DELTA) {
ALLOC_GROW(ref_deltas, nr_ref_deltas + 1, ref_deltas_alloc);
hashcpy(ref_deltas[nr_ref_deltas].sha1, ref_delta_sha1);
ref_deltas[nr_ref_deltas].obj_no = i;
@@ -1136,7 +1136,7 @@ static void parse_pack_objects(unsigned char *sha1)
obj->real_type = OBJ_BAD;
nr_delays++;
} else
- sha1_object(data, NULL, obj->size, obj->type, obj->idx.sha1);
+ sha1_object(data, NULL, obj->size, obj->in_pack_type, obj->idx.sha1);
free(data);
display_progress(progress, i+1);
}
@@ -1161,8 +1161,8 @@ static void parse_pack_objects(unsigned char *sha1)
struct object_entry *obj = &objects[i];
if (obj->real_type != OBJ_BAD)
continue;
- obj->real_type = obj->type;
- sha1_object(NULL, obj, obj->size, obj->type, obj->idx.sha1);
+ obj->real_type = obj->in_pack_type;
+ sha1_object(NULL, obj, obj->size, obj->in_pack_type, obj->idx.sha1);
nr_delays--;
}
if (nr_delays)
@@ -1215,7 +1215,7 @@ static void resolve_deltas(void)
for (i = 0; i < nr_objects; i++) {
struct object_entry *obj = &objects[i];
- if (is_delta_type(obj->type))
+ if (is_delta_type(obj->in_pack_type))
continue;
resolve_base(obj);
display_progress(progress, nr_resolved_deltas);
@@ -1314,7 +1314,7 @@ static struct object_entry *append_obj_to_pack(struct sha1file *f,
sha1write(f, header, n);
obj[0].size = size;
obj[0].hdr_size = n;
- obj[0].type = type;
+ obj[0].in_pack_type = type;
obj[0].real_type = type;
obj[1].idx.offset = obj[0].idx.offset + n;
obj[1].idx.offset += write_compressed(f, buf, size);
@@ -1566,7 +1566,7 @@ static void show_pack_info(int stat_only)
for (i = 0; i < nr_objects; i++) {
struct object_entry *obj = &objects[i];
- if (is_delta_type(obj->type))
+ if (is_delta_type(obj->in_pack_type))
chain_histogram[obj_stat[i].delta_depth - 1]++;
if (stat_only)
continue;
@@ -1575,7 +1575,7 @@ static void show_pack_info(int stat_only)
typename(obj->real_type), obj->size,
(unsigned long)(obj[1].idx.offset - obj->idx.offset),
(uintmax_t)obj->idx.offset);
- if (is_delta_type(obj->type)) {
+ if (is_delta_type(obj->in_pack_type)) {
struct object_entry *bobj = &objects[obj_stat[i].base_object_no];
printf(" %u %s", obj_stat[i].delta_depth, sha1_to_hex(bobj->idx.sha1));
}
--
2.3.0.rc1.137.g477eb31
next prev parent reply other threads:[~2015-07-08 11:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-18 10:47 [PATCH 0/2] nd/slim-index-pack-memory-usage update Nguyễn Thái Ngọc Duy
2015-04-18 10:47 ` [PATCH 1/2] index-pack: reduce object_entry size to save memory Nguyễn Thái Ngọc Duy
2015-04-18 10:47 ` [PATCH 2/2] index-pack: kill union delta_base " Nguyễn Thái Ngọc Duy
2015-07-03 16:51 ` Junio C Hamano
2015-07-03 18:29 ` Duy Nguyen
2015-07-04 1:21 ` [PATCH] index-pack: fix overallocation of sorted_by_pos array Junio C Hamano
2015-07-04 22:30 ` [PATCH] index-pack: fix allocation " Junio C Hamano
2015-07-06 23:23 ` Junio C Hamano
2015-07-07 0:36 ` Duy Nguyen
2015-07-07 15:49 ` Junio C Hamano
2015-07-07 16:06 ` Jeff King
2015-07-08 11:56 ` Nguyễn Thái Ngọc Duy [this message]
2015-07-08 11:56 ` [PATCH 2/2] pack-objects: rename the field "type" to "real_type" Nguyễn Thái Ngọc Duy
2015-07-08 13:47 ` Jeff King
2015-07-08 13:57 ` Duy Nguyen
2015-07-08 14:11 ` Jeff King
2015-07-04 22:24 ` [PATCH 2/2] index-pack: kill union delta_base to save memory Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436356591-8148-1-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).