This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] libstdc++/36338


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]