OpenSTA
OpenSTA copied to clipboard
Remove reduntant checks from iterators
Checking if container_ is not null isn't necessary after the iterator is initialized. This PR removes these checks from hasNext methods of iterators of Map, UnorderedMap, UnorderedSet. It also refactors a little.
I measured the performance gain on grt phase on black_parrot design:
| Without my changes | With my changes |
|---|---|
| 9:38.70 | 9:31.69 |
| 9:38.91 | 9:31.36 |
| 9:38.23 | 9:32.53 |
| 9:38.00 | 9:30.78 |
| 9:30.53 | 9:35.83 |
| 9:22.26 | 9:27.77 |
| 9:23.32 | 9:13.49 |
| 9:20.93 | 9:13.94 |
| 9:20.02 | 9:13.02 |
| 9:21.25 | 9:13.78 |
The average gain is slightly less than 1%. It probably speeds up other phases too.
There are still such checks in Set and Vector. When I removed them, I got seg faults. I think that some iterators weren't initialized before the iteration. I haven't tried to fix that yet.