[devel] [PATCH for apt 01/38] Replace post-increments with pre-increments

Aleksei Nikiforov darktemplar на altlinux.org
Ср Дек 11 11:11:55 MSK 2019


11.12.2019 10:51, Aleksei Nikiforov пишет:
> 10.12.2019 21:21, Alexey Tourbin пишет:
>> On Tue, Dec 10, 2019 at 6:25 PM Aleksei Nikiforov
>> <darktemplar на altlinux.org> wrote:
>>> +++ b/apt/apt-pkg/acquire-item.cc
>>> @@ -486,7 +486,7 @@ void pkgAcqIndexRel::Done(const string 
>>> &Message,unsigned long long Size,const st
>>>
>>>           bool found = false;
>>>           for (vector<string>::const_iterator I = 
>>> Repository->FingerPrint.begin();
>>> -             I != Repository->FingerPrint.end(); I++)
>>> +             I != Repository->FingerPrint.end(); ++I)
>>>           {
>>>              // Match fingerprint of Release file
>>>              if ((*I) == FingerPrint)
>>
>> How does that fix anything? It doesn't! Avoid unnecessary changes,
>> only make those beaming with thought.  As Pouchkine wrote, "strashisya
>> uchasti bessmyslennykh pevtsov".
> 
> You're right, but not the way you think you are :)
> 
> In order for this fix to matter, signature of operator++ should be fixed 
> as well. Currently it's not a standard, and returns not an object copy 
> or reference to object, but returns void. I'll fix it too and this 
> change would matter :)
> 

I've re-read contents of this patch, and it includes only operator 
changes for standard iterators, so everything is fine with this patch. 
Although, unstandard operators from Apt code may be improved as I wrote 
in my last message.

As for your original question, switching post-increments to 
pre-increments for non-fundamental types (i.e. objects like iterators) 
either improves compile-time performance or improves run-time performance.

>> _______________________________________________
>> Devel mailing list
>> Devel на lists.altlinux.org
>> https://lists.altlinux.org/mailman/listinfo/devel
>>
> _______________________________________________
> Devel mailing list
> Devel на lists.altlinux.org
> https://lists.altlinux.org/mailman/listinfo/devel


Подробная информация о списке рассылки Devel