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:
parent
ea0a1b743a
commit
c97ba6b928
10
src/dsc.h
10
src/dsc.h
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user