Closed yhabteab closed 2 years ago
std::distance
also has a constant time complexity with random-access iterators and since vectors do have a support for random-access iterators, it's the same overhead as vector::size()
. So, I'm going to close this!
Describe the bug
IcingaDB::ChunkObjects()
usesstd::distance
repeatedly to increment the offset iterator by the chunk size each time. However, this computation can also be accomplished throughobjects.size()
, which only has a constant time complexity compared to std::distance in a while loop. https://github.com/Icinga/icinga2/blob/3a8abdcc3b85a3be62a0805b465e5fac55ae0538/lib/icingadb/icingadb-objects.cpp#L558-L561A minor detail: Replace
boost::intrusive_ptr<ConfigObject>
with our::Ptr
for theIcingaDB::ChunkObjects()
return type andobjects
parameter. https://github.com/Icinga/icinga2/blob/3a8abdcc3b85a3be62a0805b465e5fac55ae0538/lib/icingadb/icingadb-objects.cpp#L553-L554