From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: Re: [JGIT PATCH 3/4] The git config file is case insensitive
Date: Sun, 12 Oct 2008 19:36:36 -0700 [thread overview]
Message-ID: <20081013023636.GK4856@spearce.org> (raw)
In-Reply-To: <1223851860-13068-4-git-send-email-robin.rosenberg@dewire.com>
Robin Rosenberg <robin.rosenberg@dewire.com> wrote:
> diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java
> index 45c2f8a..7a34cde 100644
> --- a/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java
> @@ -682,7 +683,12 @@ public void load() throws IOException {
>
> private void clear() {
> entries = new ArrayList<Entry>();
> - byName = new HashMap<String, Object>();
> + byName = new TreeMap<String, Object>(new Comparator<String>() {
> +
> + public int compare(String o1, String o2) {
> + return o1.compareToIgnoreCase(o2);
> + }
> + });
> }
This isn't necessary. Everyone who does a get or a put against the
byName map already is forming a lower case key string. I'd rather
keep the lookup O(1) than O(log N), especially if the code has a
ton of .toLowerCase() calls in it to normalize the keys.
If you are going to change it to a TreeMap with a custom Comparator
then maybe we should cleanup the code that operates on byName so it
can use the original input strings, instead of the .toLowerCase()
forms.
For now I'm going to apply your patch without this one hunk. If you
want to switch to a TreeMap lets also cleanup the get/put calls.
--
Shawn.
prev parent reply other threads:[~2008-10-13 2:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-12 22:50 [JGIT PATCH 0/4] Decodings Robin Rosenberg
2008-10-12 22:50 ` [JGIT PATCH 1/4] log command: Use explicit US locale for dates Robin Rosenberg
2008-10-12 22:50 ` [JGIT PATCH 2/4] jgit programs: Use i18n.logOutputEncoding or user's locale for output Robin Rosenberg
2008-10-12 22:50 ` [JGIT PATCH 3/4] The git config file is case insensitive Robin Rosenberg
2008-10-12 22:51 ` [JGIT PATCH 4/4] Intelligent parsing of ambiguously encoded meta data Robin Rosenberg
2008-10-13 2:27 ` Shawn O. Pearce
2008-10-13 17:10 ` Robin Rosenberg
2008-10-13 2:36 ` Shawn O. Pearce [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081013023636.GK4856@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg@dewire.com \
/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.
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 NNTP newsgroup(s).