git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Antoine Pelisse <apelisse@gmail.com>
Cc: git <git@vger.kernel.org>
Subject: Re: [PATCH 01/10] list_lookup: create case and length search
Date: Sat, 05 Jan 2013 14:39:18 -0800	[thread overview]
Message-ID: <7vmwwnp84p.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1357421206-5014-2-git-send-email-apelisse@gmail.com> (Antoine Pelisse's message of "Sat, 5 Jan 2013 22:26:37 +0100")

Antoine Pelisse <apelisse@gmail.com> writes:

> 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?

  reply	other threads:[~2013-01-05 22:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-05 21:26 [PATCH 00/10] Log mailmap optimization Antoine Pelisse
2013-01-05 21:26 ` [PATCH 01/10] list_lookup: create case and length search Antoine Pelisse
2013-01-05 22:39   ` Junio C Hamano [this message]
2013-01-07 22:37     ` Junio C Hamano
2013-01-05 21:26 ` [PATCH 02/10] Use split_ident_line to parse author and committer Antoine Pelisse
2013-01-05 21:26 ` [PATCH 03/10] mailmap: remove email copy and length limitation Antoine Pelisse
2013-01-05 21:26 ` [PATCH 04/10] mailmap: simplify map_user() interface Antoine Pelisse
2013-01-06 22:56   ` Junio C Hamano
2013-01-05 21:26 ` [PATCH 05/10] mailmap: add mailmap structure to rev_info and pp Antoine Pelisse
2013-01-05 21:26 ` [PATCH 06/10] pretty: use mailmap to display username and email Antoine Pelisse
2013-01-05 21:26 ` [PATCH 07/10] log: add --use-mailmap option Antoine Pelisse
2013-01-05 21:26 ` [PATCH 08/10] test: add test for " Antoine Pelisse
2013-01-05 21:26 ` [PATCH 09/10] log: grep author/committer using mailmap Antoine Pelisse
2013-01-05 21:26 ` [PATCH 10/10] log: add log.mailmap configuration option Antoine Pelisse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vmwwnp84p.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=apelisse@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).