This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Remove algo logic duplication Round 3
- From: Christopher Jefferson <chris at bubblescope dot net>
- To: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Sun, 29 Sep 2013 21:19:11 +0100
- Subject: Re: Remove algo logic duplication Round 3
- Authentication-results: sourceware.org; auth=none
- References: <52409F6F dot 7040609 at gmail dot com> <alpine dot DEB dot 2 dot 10 dot 1309232317070 dot 4088 at laptop-mg dot saclay dot inria dot fr> <alpine dot DEB dot 2 dot 10 dot 1309290031480 dot 4104 at laptop-mg dot saclay dot inria dot fr>
On 28 September 2013 23:49, Marc Glisse <marc.glisse@inria.fr> wrote:
> Hello,
>
> using the program below, it seems to me that to sort the array {1,2}, we do
> 9 copies of the comparison functor, and 13 iterator copies (used to be 4 and
> 8). As long as those are empty or pointers, that's free. But if copying has
> even a slight cost for the functor or the iterator, it is quickly going to
> be noticable.
>
> Maybe we could use more references? The user-facing functions have to take
> iterators by value, but I think the inline helpers could use references.
I think this is good idea. It might also be worth force_inlining some
of the internal functions, even it they are large, where we have
introduced a forwarding function (this won't make code bigger, if we
are the only caller of a templated function, with a particular
instansiation of the comparison template parameter).
>
> (we also perform 2 comparisons where one should be enough, but that's a
> different issue)
That is worth looking at (although increasingly, I want to investigate
doing a fresh sort altogether. In my own code I use an implementation
of timsort, which shows much better performance where data is partly
sorted. However, that's a different patch/discussion!)
Chris