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

Re: Question About Sorting the Index

From
Junio C Hamano <gitster@pobox.com>
Date
May 28, 2025, 02:34 UTC
Message-ID
<xmqqbjrdtqed.fsf@gitster.g>
In-Reply-To
<9befdb3e-ff6e-4416-8735-1eea99dbbf01@gmail.com>
Jon Forrest <nobozo@gmail.com> writes:
Show 10 quoted lines
> On 5/17/25 11:36 AM, Junio C Hamano wrote:
>
>> For example, the fact that the index is first read into core, each
>> entry is represented as a cache_entry in-core structure, and the
>> code accesses them via an array active_cache[], and that array is
>> sorted per pathnames, haven't changed.  
>
> I had a thought. What if the in-memory cache were stored in a hash,
> where the pathname is the key? That way nothing would have to be
> sorted in order to lookup a particular file.

The index must be in sorted order in order to allow a set of tree objects written out of it. Hash may be good for looking up, but it is not the best data structure for stable and efficient enumeration.

Previous: Jon Forrest
Message 9 of 9 in “Question About Sorting the Index”
  1. Jon ForrestMay 16, 2025
  2. Re Question About Sorting the IndexK Jayatheerth, May 17, 2025
  3. Jon ForrestMay 17, 2025
  4. Junio C HamanoMay 17, 2025
  5. Jon ForrestMay 17, 2025
  6. Elijah NewrenMay 18, 2025
  7. Jon ForrestMay 18, 2025
  8. Jon ForrestMay 27, 2025
  9. Junio C HamanoMay 28, 2025

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.