Optimize IdList::MaximumId() from O(n) to O(1).

This specific implementation seems to have lingered from the days
before IdList was stored sorted. This commit has resulted in a ~5%
improvement in Generate::DIRTY time for modelisation.slvs on a GCC 6
release build.
This commit is contained in:
whitequark 2016-11-17 14:14:56 +00:00
parent ea0a1b743a
commit c97ba6b928

View File

@ -270,13 +270,11 @@ public:
int elemsAllocated; int elemsAllocated;
uint32_t MaximumId() { uint32_t MaximumId() {
uint32_t id = 0; if(n == 0) {
return 0;
int i; } else {
for(i = 0; i < n; i++) { return elem[n - 1].h.v;
id = max(id, elem[i].h.v);
} }
return id;
} }
H AddAndAssignId(T *t) { H AddAndAssignId(T *t) {