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

Re: [PATCH 4/6] alloc.[ch]: remove alloc_report() function

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 19, 2021, 19:42 UTC
Message-ID
<xmqqh7c8orua.fsf@gitster.g>
In-Reply-To
<patch-4.6-bd8aa9b1554-20211119T124420Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
> The alloc_report() function has been orphaned since its introduction
> in 855419f764a (Add specialized object allocator, 2006-06-19), it
> appears to have been used for demonstration purposes in that commit
> message.

Stopping a program in debugger, and calling these functions that have otherwise no callers, is a fairly handy way to debug. It is likely that we used it while developing the allocator.

If we truly want to get rid of it, we'd want to lose the "count" member from the alloc_state structure, which is otherwise unused, I would think.

Even though I do not think 5/6 and 6/6 in this series are good idea, I am on the fence on this one, slightly leaning to "lose it" but not that strongly.

Show 46 quoted lines
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  alloc.c | 19 -------------------
>  alloc.h |  1 -
>  2 files changed, 20 deletions(-)
>
> diff --git a/alloc.c b/alloc.c
> index 957a0af3626..bf7982712f1 100644
> --- a/alloc.c
> +++ b/alloc.c
> @@ -122,22 +122,3 @@ void *alloc_commit_node(struct repository *r)
>  	init_commit_node(c);
>  	return c;
>  }
> -
> -static void report(const char *name, unsigned int count, size_t size)
> -{
> -	fprintf(stderr, "%10s: %8u (%"PRIuMAX" kB)\n",
> -			name, count, (uintmax_t) size);
> -}
> -
> -#define REPORT(name, type)	\
> -    report(#name, r->parsed_objects->name##_state->count, \
> -		  r->parsed_objects->name##_state->count * sizeof(type) >> 10)
> -
> -void alloc_report(struct repository *r)
> -{
> -	REPORT(blob, struct blob);
> -	REPORT(tree, struct tree);
> -	REPORT(commit, struct commit);
> -	REPORT(tag, struct tag);
> -	REPORT(object, union any_object);
> -}
> diff --git a/alloc.h b/alloc.h
> index 371d388b552..3f4a0ad310a 100644
> --- a/alloc.h
> +++ b/alloc.h
> @@ -13,7 +13,6 @@ void init_commit_node(struct commit *c);
>  void *alloc_commit_node(struct repository *r);
>  void *alloc_tag_node(struct repository *r);
>  void *alloc_object_node(struct repository *r);
> -void alloc_report(struct repository *r);
>  
>  struct alloc_state *allocate_alloc_state(void);
>  void clear_alloc_state(struct alloc_state *s);
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 9 of 51 in “various: remove dead code”
  1. 0/6 various: remove dead codeÆvar Arnfjörð Bjarmason, Nov 19, 2021
  2. 1/6 xdiff/xmacros.h: remove unused XDL_PTRFREEÆvar Arnfjörð Bjarmason, Nov 19, 2021
  3. Jeff KingNov 19, 2021
  4. 2/6 pack-bitmap-write: remove unused bitmap_reset() functionÆvar Arnfjörð Bjarmason, Nov 19, 2021
  5. Jeff KingNov 19, 2021
  6. 3/6 object-store.h: remove unused has_sha1_file*()Ævar Arnfjörð Bjarmason, Nov 19, 2021
  7. Jeff KingNov 19, 2021
  8. 4/6 alloc.[ch]: remove alloc_report() functionÆvar Arnfjörð Bjarmason, Nov 19, 2021
  9. Junio C HamanoNov 19, 2021
  10. 5/6 strbuf: remove unused istarts_with() functionÆvar Arnfjörð Bjarmason, Nov 19, 2021
  11. Jeff KingNov 19, 2021
  12. Junio C HamanoNov 19, 2021
  13. 6/6 json-writer.[ch]: remove unused formatting functionsÆvar Arnfjörð Bjarmason, Nov 19, 2021
  14. Jeff KingNov 19, 2021
  15. Junio C HamanoNov 19, 2021
  16. Jeff KingNov 19, 2021
  17. 0/5 various: remove dead codeÆvar Arnfjörð Bjarmason, Nov 19, 2021
  18. 1/5 xdiff/xmacros.h: remove unused XDL_PTRFREEÆvar Arnfjörð Bjarmason, Nov 19, 2021
  19. 2/5 pack-bitmap-write: remove unused bitmap_reset() functionÆvar Arnfjörð Bjarmason, Nov 19, 2021
  20. 5/5 json-writer.[ch]: remove unused formatting functionsÆvar Arnfjörð Bjarmason, Nov 19, 2021
  21. 4/5 alloc.[ch]: remove alloc_report() functionÆvar Arnfjörð Bjarmason, Nov 19, 2021
  22. 3/5 object-store.h: remove unused has_sha1_file*()Ævar Arnfjörð Bjarmason, Nov 19, 2021
  23. 0/7 various: remove dead code, drop i18n not used in-treeÆvar Arnfjörð Bjarmason, Mar 26, 2022
  24. 1/7 run-command.h: remove always unused "clean_on_exit_handler_cbdata"Ævar Arnfjörð Bjarmason, Mar 26, 2022
  25. 4/7 pack-bitmap-write: remove unused bitmap_reset() functionÆvar Arnfjörð Bjarmason, Mar 26, 2022
  26. 3/7 xdiff/xmacros.h: remove unused XDL_PTRFREEÆvar Arnfjörð Bjarmason, Mar 26, 2022
  27. 2/7 configure.ac: remove USE_PIC commentÆvar Arnfjörð Bjarmason, Mar 26, 2022
  28. 5/7 object-store.h: remove unused has_sha1_file*()Ævar Arnfjörð Bjarmason, Mar 26, 2022
  29. 6/7 alloc.[ch]: remove alloc_report() functionÆvar Arnfjörð Bjarmason, Mar 26, 2022
  30. 7/7 git-sh-setup: don't mark trees not used in-tree for i18nÆvar Arnfjörð Bjarmason, Mar 26, 2022
  31. Johannes SixtMar 27, 2022
  32. Ævar Arnfjörð BjarmasonMar 27, 2022
  33. Johannes SixtMar 28, 2022
  34. Ævar Arnfjörð BjarmasonMar 28, 2022
  35. Johannes SixtMar 28, 2022
  36. Phillip WoodMar 31, 2022
  37. Ævar Arnfjörð BjarmasonMar 31, 2022
  38. Johannes SixtMar 31, 2022
  39. Ævar Arnfjörð BjarmasonApr 2, 2022
  40. Johannes SixtApr 2, 2022
  41. Ævar Arnfjörð BjarmasonApr 3, 2022
  42. Johannes SixtApr 4, 2022
  43. 0/6 various: remove dead codeÆvar Arnfjörð Bjarmason, Mar 31, 2022
  44. 1/6 run-command.h: remove always unused "clean_on_exit_handler_cbdata"Ævar Arnfjörð Bjarmason, Mar 31, 2022
  45. Junio C HamanoMar 31, 2022
  46. 3/6 xdiff/xmacros.h: remove unused XDL_PTRFREEÆvar Arnfjörð Bjarmason, Mar 31, 2022
  47. 4/6 pack-bitmap-write: remove unused bitmap_reset() functionÆvar Arnfjörð Bjarmason, Mar 31, 2022
  48. Junio C HamanoMar 31, 2022
  49. 5/6 object-store.h: remove unused has_sha1_file*()Ævar Arnfjörð Bjarmason, Mar 31, 2022
  50. 6/6 alloc.[ch]: remove alloc_report() functionÆvar Arnfjörð Bjarmason, Mar 31, 2022
  51. 2/6 configure.ac: remove USE_PIC commentÆvar Arnfjörð Bjarmason, Mar 31, 2022

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.