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

Re: [PATCH] prio-queue: fold lazy_queue into prio_queue for automatic get+put fusion

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 8, 2026, 14:07 UTC
Message-ID
<xmqqldcpxh0n.fsf@gitster.g>
In-Reply-To
<CAL71e4MbC+tdTuN6p1HiHtE1XYuS1gBM-KSejFZJ1wbftxNveg@mail.gmail.com>
Kristofer Karlsson <krka@spotify.com> writes:
Show 6 quoted lines
> Agreed, that's the right fix. I looked for existing ways of marking
> fields as private, internal or hidden but the only thing I found was
> the convention of using a code comment: /* for internal use only */
>
> I will apply a rename and submit a v2. Perhaps something like
> nr_internal to make it look less like a public API.

I think we often use trailing underscore (e.g., "n_") to mark variables for "not to be used casually, there are better ways to access this information", which pre-ANSI C people probably used leading underscore (e.g. "_n") for.

This is often used in callback functions where the types of their formal parameters are specified by the API and use of them with casting at every use site is awkward. For example, qsort() and friends often take a pointer to the location that stores the value to be compared, but it is awkward, so we do cast just once upfront like so:

static int compare_callback(const void *a_, const void *b_)
{
	const a_type a = *((const a_type *)a_);
	const a_type b = *((const a_type *)b_);
        ... use values 'a' and 'b', without having to cast a_ or b_ ...
	return a - b;
}

I think the technique/convention can be used in a similar way for "this is hidden and unless you can tell if you should be using it directly, you probably shouldn't" kind of structure members.

So, nr_internal is perfectly fine, but if you find it too long, nr_ is probably just as good.

Previous: Kristofer KarlssonNext: Kristofer Karlsson via GitGitGadget
Message 4 of 18 in “prio-queue: fold lazy_queue into prio_queue for automatic get+put fusion”
  1. prio-queue: fold lazy_queue into prio_queue for automatic get+put fusionKristofer Karlsson via GitGitGadget, Jun 6, 2026
  2. Junio C HamanoJun 6, 2026
  3. Kristofer KarlssonJun 6, 2026
  4. Junio C HamanoJun 8, 2026
  5. 0/2 prio-queue: fold lazy_queue into prio_queue for automatic get+put fusionKristofer Karlsson via GitGitGadget, Jun 6, 2026
  6. 1/2 prio-queue: fold lazy_queue into prio_queue for automatic get+put fusionKristofer Karlsson via GitGitGadget, Jun 6, 2026
  7. 2/2 prio-queue: rename .nr to .nr_internal to prevent direct accessKristofer Karlsson via GitGitGadget, Jun 6, 2026
  8. René ScharfeJun 7, 2026
  9. Kristofer KarlssonJun 7, 2026
  10. 0/2 prio-queue: fold lazy_queue into prio_queue for automatic get+put fusionKristofer Karlsson via GitGitGadget, Jun 7, 2026
  11. 1/2 prio-queue: fold lazy_queue into prio_queue for automatic get+put fusionKristofer Karlsson via GitGitGadget, Jun 7, 2026
  12. 2/2 prio-queue: rename .nr to .nr_internal to prevent direct accessKristofer Karlsson via GitGitGadget, Jun 7, 2026
  13. Junio C HamanoJun 8, 2026
  14. 0/2 prio-queue: fold lazy_queue into prio_queue for automatic get+put fusionKristofer Karlsson via GitGitGadget, Jun 8, 2026
  15. 1/2 prio-queue: rename .nr to .nr_ and add accessor helpersKristofer Karlsson via GitGitGadget, Jun 8, 2026
  16. 2/2 prio-queue: fold lazy_queue into prio_queue for automatic get+put fusionKristofer Karlsson via GitGitGadget, Jun 8, 2026
  17. Junio C HamanoJun 30, 2026
  18. Kristofer KarlssonJun 30, 2026

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.