{"thread":{"id":"8359","subject":"[PATCH 1/3] Simplify index access condition in count-objects, pack-redundant","startedAt":"2007-05-30T06:12:28Z","lastAt":"2007-05-30T06:12:28Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"43617","messageId":"20070530061228.GA12738@spearce.org","threadId":"8359","inReplyTo":null,"subject":"[PATCH 1/3] Simplify index access condition in count-objects, pack-redundant","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-05-30T06:12:28Z","receivedAt":"2007-05-30T06:12:28Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"My earlier lazy index opening patch changed this condition to check\nindex_data and call open_pack_index if it was NULL. In truth we only\ncare about num_objects.  Since open_pack_index does no harm if the\nindex is already open, and all indexes are likely to be closed in\nthis application, the \"performance optimization\" of inlining the\nindex_data check here was wrong.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\n First of a 3 part series to cleanup behind the lazy index patch.\n This particular one was stupid; the lazy index patch never should\n have been submitted with the conditions like this.\n\n After this series, I'm pretty sure we've got everything covered.\n Additional eyes from other people wouldn't hurt, but I have gone\n through every caller several times now and am pretty sure they\n are all correct.\n\n Note that we are *not* safe to unload an index once opened; unlike\n the use_pack() interface the index_data interface does not offer a\n way for a caller to pin the index_data into memory for the duration\n of the block.  That's one reason I haven't tried to GC indexes yet.\n\n builtin-count-objects.c |    2 +-\n pack-redundant.c        |    2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-count-objects.c b/builtin-count-objects.c\nindex ac65e03..4274ec1 100644\n--- a/builtin-count-objects.c\n+++ b/builtin-count-objects.c\n@@ -111,7 +111,7 @@ int cmd_count_objects(int ac, const char **av, const char *prefix)\n \t\tfor (p = packed_git; p; p = p->next) {\n \t\t\tif (!p->pack_local)\n \t\t\t\tcontinue;\n-\t\t\tif (!p->index_data && open_pack_index(p))\n+\t\t\tif (open_pack_index(p))\n \t\t\t\tcontinue;\n \t\t\tpacked += p->num_objects;\n \t\t\tnum_pack++;\ndiff --git a/pack-redundant.c b/pack-redundant.c\nindex 0617320..6bc3bdf 100644\n--- a/pack-redundant.c\n+++ b/pack-redundant.c\n@@ -550,7 +550,7 @@ static struct pack_list * add_pack(struct packed_git *p)\n \tl.pack = p;\n \tllist_init(&l.all_objects);\n \n-\tif (!p->index_data && open_pack_index(p))\n+\tif (open_pack_index(p))\n \t\treturn NULL;\n \n \tbase = p->index_data;\n-- \n1.5.2.869.g6b3ba\n"}]}