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

Re: [PATCH 01/10] list_lookup: create case and length search

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 5, 2013, 22:39 UTC
Message-ID
<7vmwwnp84p.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1357421206-5014-2-git-send-email-apelisse@gmail.com>
Antoine Pelisse <apelisse@gmail.com> writes:
Show 10 quoted lines
> Create a new function to look-up a string in a string_list, but:
>  - add a new parameter to ignore case differences
>  - add a length parameter to search for a substring
>
> The idea is to avoid several copies (lowering a string before searching
> it when we just want to ignore case), or copying a substring of a bigger
> string to search it in the string_list
>
> Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
> ---

I did not read beyond the log message and the function signature of the updated get_entry_index(), but it strikes me insane to build a sorted list using case sensitive full string comarison and then to look for an element in that list using a different comparison criteria (e.g. case insensitive comparison) and to expect the bisection search to still work. Shouldn't the codepath that builds the string-list be sorting the list in case insensitive way from the beginning if this were to work correctly?

It seems to suggest to me that this "are the keys case sensitive?" bit belongs to the entire struct string_list structure as its property (similar to the way "do the keys need to be strdup'ed?" bit), not something you would flip per invocation basis of the lookup function.

Also isn't size_t an unsigned type? What does it even mean to pass "-1" to it, and propagate it down to strncmp()?

If you have a list sorted by a key, and if you want to query it with a partial prefix of a possibly valid key, I think you shouldn't have to add the "length search" at all. The existing look up function would return the location in the list that short key would have been inserted, which would come before the first entry that your short key is a prefix of, so the caller can iterate the list from there to find all entries. In other words, if existing list has "aaa", "bba", and "bbc", and you want to grab entries that begin with "bb", you can ask for "bb" to the loop up function, which would say "the key does not exist in the list, but it would be inserted before this 'bba' entry". Then you can discover that "bba" and "bbc" both matches the shortened key you have, no?

Previous: Antoine PelisseNext: Junio C Hamano
Message 3 of 14 in “Log mailmap optimization”
  1. 00/10 Log mailmap optimizationAntoine Pelisse, Jan 5, 2013
  2. 01/10 list_lookup: create case and length searchAntoine Pelisse, Jan 5, 2013
  3. Junio C HamanoJan 5, 2013
  4. Junio C HamanoJan 7, 2013
  5. 02/10 Use split_ident_line to parse author and committerAntoine Pelisse, Jan 5, 2013
  6. 03/10 mailmap: remove email copy and length limitationAntoine Pelisse, Jan 5, 2013
  7. 04/10 mailmap: simplify map_user() interfaceAntoine Pelisse, Jan 5, 2013
  8. Junio C HamanoJan 6, 2013
  9. 05/10 mailmap: add mailmap structure to rev_info and ppAntoine Pelisse, Jan 5, 2013
  10. 06/10 pretty: use mailmap to display username and emailAntoine Pelisse, Jan 5, 2013
  11. 07/10 log: add --use-mailmap optionAntoine Pelisse, Jan 5, 2013
  12. 08/10 test: add test for --use-mailmap optionAntoine Pelisse, Jan 5, 2013
  13. 09/10 log: grep author/committer using mailmapAntoine Pelisse, Jan 5, 2013
  14. 10/10 log: add log.mailmap configuration optionAntoine Pelisse, Jan 5, 2013

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.