git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: jk/loose-object-cache

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 7, 2019, 19:29 UTC
Message-ID
<xmqqo98s8dwv.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<3512c798-aa42-6fba-ee82-d33a8985be91@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 6 quoted lines
> Am 28.12.2018 um 19:04 schrieb Junio C Hamano:
>> * jk/loose-object-cache (2018-11-24) 10 commits
> ...
> So this has hit master in the meantime.  We discussed a sort performance
> fix in [1]; I'll reply with a short series containing a cleaned-up and
> rebased version as a follow-up.
Thanks.
-- >8 --
Subject: [PATCH 4/3] sha1-file.c: make odb_load_loose_cache() static

Now there is only a single internal caller to this helper function that knows the implementation detail of the cache too much, hide it from outside world by making it static.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 object-store.h |  7 -------
 sha1-file.c    | 24 +++++++++++++++---------
 2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/object-store.h b/object-store.h
index 2fb6c0e4db..e16aa38cae 100644
--- a/object-store.h
+++ b/object-store.h
@@ -47,13 +47,6 @@ void add_to_alternates_file(const char *dir);
  */
 void add_to_alternates_memory(const char *dir);
 
-/*
- * Populate an odb's loose object cache for one particular subdirectory (i.e.,
- * the one that corresponds to the first byte of objects you're interested in,
- * from 0 to 255 inclusive).
- */
-void odb_load_loose_cache(struct object_directory *odb, int subdir_nr);
-
 /*
  * Populate and return the loose object cache array corresponding to the
  * given object ID.
diff --git a/sha1-file.c b/sha1-file.c
index 2adc56cde4..936d216ad4 100644
--- a/sha1-file.c
+++ b/sha1-file.c
@@ -2150,15 +2150,12 @@ static int append_loose_object(const struct object_id *oid, const char *path,
 	return 0;
 }
 
-struct oid_array *odb_loose_cache(struct object_directory *odb,
-				  const struct object_id *oid)
-{
-	int subdir_nr = oid->hash[0];
-	odb_load_loose_cache(odb, subdir_nr);
-	return &odb->loose_objects_cache[subdir_nr];
-}
-
-void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)
+/*
+ * Populate an odb's loose object cache for one particular subdirectory (i.e.,
+ * the one that corresponds to the first byte of objects you're interested in,
+ * from 0 to 255 inclusive).
+ */
+static void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)
 {
 	struct strbuf buf = STRBUF_INIT;
 
@@ -2178,6 +2175,15 @@ void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)
 	strbuf_release(&buf);
 }
 
+struct oid_array *odb_loose_cache(struct object_directory *odb,
+				  const struct object_id *oid)
+{
+	int subdir_nr = oid->hash[0];
+	odb_load_loose_cache(odb, subdir_nr);
+	return &odb->loose_objects_cache[subdir_nr];
+}
+
+
 void odb_clear_loose_cache(struct object_directory *odb)
 {
 	int i;
Previous: Junio C Hamano
Message 45 of 45 in “What's cooking in git.git (Dec 2018, #02; Fri, 28)”
  1. Junio C HamanoDec 28, 2018
  2. Elijah NewrenDec 28, 2018
  3. Johannes SchindelinJan 3, 2019
  4. Elijah NewrenJan 7, 2019
  5. ag/sequencer-reduce-rewriting-todo, was Re: What's cooking in git.git (Dec 2018, #02; Fri, 28)Alban Gruin, Dec 28, 2018
  6. Junio C HamanoDec 28, 2018
  7. Denton LiuDec 29, 2018
  8. ps/stash-in-c, was Re: What's cooking in git.git (Dec 2018, #02; Fri, 28)Johannes Schindelin, Jan 3, 2019
  9. jk/loose-object-cacheRené Scharfe, Jan 6, 2019
  10. 1/3 object-store: factor out odb_loose_cache()René Scharfe, Jan 6, 2019
  11. Jeff KingJan 7, 2019
  12. René ScharfeJan 7, 2019
  13. René ScharfeJan 7, 2019
  14. Philip OakleyJan 7, 2019
  15. Jeff KingJan 7, 2019
  16. René ScharfeJan 7, 2019
  17. 2/3 object-store: factor out odb_clear_loose_cache()René Scharfe, Jan 6, 2019
  18. 3/3 object-store: use one oid_array per subdirectory for loose cacheRené Scharfe, Jan 6, 2019
  19. Ævar Arnfjörð BjarmasonJan 6, 2019
  20. René ScharfeJan 6, 2019
  21. 0/11 jk/loose-object-cache sha1/object_id fixupsJeff King, Jan 7, 2019
  22. 01/11 sha1-file: fix outdated sha1 comment referencesJeff King, Jan 7, 2019
  23. 02/11 update comment references to sha1_object_info()Jeff King, Jan 7, 2019
  24. 03/11 http: use struct object_id instead of bare sha1Jeff King, Jan 7, 2019
  25. 04/11 sha1-file: modernize loose object file functionsJeff King, Jan 7, 2019
  26. 05/11 sha1-file: modernize loose header/stream functionsJeff King, Jan 7, 2019
  27. 06/11 sha1-file: convert pass-through functions to object_idJeff King, Jan 7, 2019
  28. 07/11 convert has_sha1_file() callers to has_object_file()Jeff King, Jan 7, 2019
  29. 08/11 sha1-file: drop has_sha1_file()Jeff King, Jan 7, 2019
  30. 09/11 sha1-file: prefer "loose object file" to "sha1 file" in messagesJeff King, Jan 7, 2019
  31. 10/11 sha1-file: avoid "sha1 file" for generic use in messagesJeff King, Jan 7, 2019
  32. 11/11 prefer "hash mismatch" to "sha1 mismatch"Jeff King, Jan 7, 2019
  33. René ScharfeJan 8, 2019
  34. Junio C HamanoJan 8, 2019
  35. Jeff KingJan 8, 2019
  36. Junio C HamanoJan 8, 2019
  37. Derrick StoleeJan 8, 2019
  38. Junio C HamanoJan 8, 2019
  39. Jeff KingJan 8, 2019
  40. Stefan BellerJan 9, 2019
  41. Stefan BellerJan 9, 2019
  42. Jeff KingJan 10, 2019
  43. 4/3 object-store: retire odb_load_loose_cache()René Scharfe, Jan 7, 2019
  44. Junio C HamanoJan 7, 2019
  45. Junio C HamanoJan 7, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.