{"thread":{"id":"5391","subject":"[PATCH 3/5] Cleanup unpack_entry_gently and friends to use type_name array.","startedAt":"2006-08-26T08:11:36Z","lastAt":"2006-08-26T08:11:36Z","messageCount":1,"participants":["Shawn Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"25927","messageId":"20060826081136.GE22343@spearce.org","threadId":"5391","inReplyTo":null,"subject":"[PATCH 3/5] Cleanup unpack_entry_gently and friends to use type_name array.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-08-26T08:11:36Z","receivedAt":"2006-08-26T08:11:36Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"[PATCH 3/5] Cleanup unpack_entry_gently and friends to use type_name array.\n\nThis change allows combining all of the non-delta entries into a\nsingle case, as well as to remove an unnecessary local variable\nin unpack_entry_gently.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n sha1_file.c |   34 ++++++----------------------------\n 1 files changed, 6 insertions(+), 28 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex fd3e01b..b580cee 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -996,16 +996,10 @@ void packed_object_info_detail(struct pa\n \t}\n \tswitch (kind) {\n \tcase OBJ_COMMIT:\n-\t\tstrcpy(type, commit_type);\n-\t\tbreak;\n \tcase OBJ_TREE:\n-\t\tstrcpy(type, tree_type);\n-\t\tbreak;\n \tcase OBJ_BLOB:\n-\t\tstrcpy(type, blob_type);\n-\t\tbreak;\n \tcase OBJ_TAG:\n-\t\tstrcpy(type, tag_type);\n+\t\tstrcpy(type, type_names[kind]);\n \t\tbreak;\n \tdefault:\n \t\tdie(\"corrupted pack file %s containing object of kind %d\",\n@@ -1036,16 +1030,10 @@ static int packed_object_info(struct pac\n \t\tunuse_packed_git(p);\n \t\treturn retval;\n \tcase OBJ_COMMIT:\n-\t\tstrcpy(type, commit_type);\n-\t\tbreak;\n \tcase OBJ_TREE:\n-\t\tstrcpy(type, tree_type);\n-\t\tbreak;\n \tcase OBJ_BLOB:\n-\t\tstrcpy(type, blob_type);\n-\t\tbreak;\n \tcase OBJ_TAG:\n-\t\tstrcpy(type, tag_type);\n+\t\tstrcpy(type, type_names[kind]);\n \t\tbreak;\n \tdefault:\n \t\tdie(\"corrupted pack file %s containing object of kind %d\",\n@@ -1143,33 +1131,23 @@ void *unpack_entry_gently(struct pack_en\n \tunsigned long offset, size, left;\n \tunsigned char *pack;\n \tenum object_type kind;\n-\tvoid *retval;\n \n \toffset = unpack_object_header(p, entry->offset, &kind, &size);\n \tpack = (unsigned char *) p->pack_base + offset;\n \tleft = p->pack_size - offset;\n \tswitch (kind) {\n \tcase OBJ_DELTA:\n-\t\tretval = unpack_delta_entry(pack, size, left, type, sizep, p);\n-\t\treturn retval;\n+\t\treturn unpack_delta_entry(pack, size, left, type, sizep, p);\n \tcase OBJ_COMMIT:\n-\t\tstrcpy(type, commit_type);\n-\t\tbreak;\n \tcase OBJ_TREE:\n-\t\tstrcpy(type, tree_type);\n-\t\tbreak;\n \tcase OBJ_BLOB:\n-\t\tstrcpy(type, blob_type);\n-\t\tbreak;\n \tcase OBJ_TAG:\n-\t\tstrcpy(type, tag_type);\n-\t\tbreak;\n+\t\tstrcpy(type, type_names[kind]);\n+\t\t*sizep = size;\n+\t\treturn unpack_compressed_entry(pack, size, left);\n \tdefault:\n \t\treturn NULL;\n \t}\n-\t*sizep = size;\n-\tretval = unpack_compressed_entry(pack, size, left);\n-\treturn retval;\n }\n \n int num_packed_objects(const struct packed_git *p)\n-- \n1.4.2.g6580\n"}]}