This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch] libstdc++/36338
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: Chris Jefferson <chris at bubblescope dot net>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 30 May 2008 01:48:11 +0200
- Subject: Re: [Patch] libstdc++/36338
- References: <483EB744.601@oracle.com> <5cc6b04e0805291638k3c3b373fibd94e5777ea46dfa@mail.gmail.com>
Hi Chris,
I might be going mad but:
while (__last - __first > 1)
- std::pop_heap(__first, _RandomAccessIterator(__last--));
+ {
+ --__last;
+ std::__pop_heap(__first, __last, __last);
+ }
}
Seeing as the original was a post-increment, shouldn't the --__last come after?
Well, first I think we would see that when running the testsuite ;)
Second, more seriously, I don't think so: because the original sort_heap
was passing __last to pop_heap, which, in turn, was passing __last - 1
to __pop_heap. Eventually, in the sort_heap loop __last was decremented .
In the new version, __last is decremented immediately, because this is
what __pop_heap wants, and we are done with it, the sort_heap iteration
is complete in the same way, __last decremented.
I think the two are completely equivalent.
Paolo.