From: David Kastrup <dak@gnu.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: Alex Riesen <raa.lkml@gmail.com>,
martin f krafft <madduck@madduck.net>,
git discussion list <git@vger.kernel.org>,
439992-quiet@bugs.debian.org
Subject: Re: [PATCH] Remove duplicate pathspecs from ls-files command line
Date: Thu, 30 Aug 2007 07:52:21 +0200 [thread overview]
Message-ID: <85myw9d0x6.fsf@lola.goethe.zz> (raw)
In-Reply-To: <7vr6llak4h.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Wed\, 29 Aug 2007 18\:25\:50 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> David Kastrup <dak@gnu.org> writes:
>
>> Does anything speak against sorting the pathspecs? That is an O(n log
>> n) operation,
>
> Not sorting is O(0) operation without losing cycles for the
> normal case. I think you can sort first in that error handling
> path to avoid O(n^2) but sorting upfront to remove duplicates
> for every case is unnecessary bloat that penalizes sane callers.
Not if you need to sort the file list anyway in order to merge it with
the index. Of course, sorting patterns will not in all cases
establish the order of their expansions.
In any case, uniqueness should be establishable when matching to the
index, regardless of whether this matching is done by sort&merge
(probably the most efficient variant) or by binary search as it is
done now if I understand correctly. I am just not happy with the
ensuing binary _insertion_ as this is an O(nm) operation when
inserting n elements into an m element data structure. A list merge
is O(n+m), in contrast, and we can access the index sequentially.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
next prev parent reply other threads:[~2007-08-30 5:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-29 8:11 double occurrence of filenames on command lines martin f krafft
2007-08-29 19:44 ` [PATCH] Remove duplicate pathspecs from ls-files command line Alex Riesen
2007-08-29 20:44 ` Junio C Hamano
2007-08-29 21:04 ` martin f krafft
2007-08-29 21:15 ` Alex Riesen
2007-08-29 21:36 ` David Kastrup
2007-08-30 1:25 ` Junio C Hamano
2007-08-30 5:52 ` David Kastrup [this message]
2007-08-29 20:57 ` martin f krafft
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=85myw9d0x6.fsf@lola.goethe.zz \
--to=dak@gnu.org \
--cc=439992-quiet@bugs.debian.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=madduck@madduck.net \
--cc=raa.lkml@gmail.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