swift
065a25fc - Reserve AllDelayed vector to upper bound.

Commit
7 years ago
Reserve AllDelayed vector to upper bound. File: [swift/lib/Parse/PersistentParserState.cpp] Observing this code snipped closely in function, [void PersistentParserState::parseAllDelayedDeclLists()]: ``` for (auto &P: DelayedDeclListStates) { AllDelayed.push_back(P.first); } ``` We observe that 'AllDelayed' gets maximum of DelayedDeclListStates.size() elements pushed into it. So it is better to reserve 'vector AllDelayed' to that max size, to save reallocation cost. I believe we can use size() on [DelayedDeclListStates], which is of type: ```llvm::DenseMap<IterableDeclContext *, std::unique_ptr<DelayedDeclListState>>``` because of the ```DenseMapIterator``` implementation of size(). [http://llvm.org/doxygen/DenseMap_8h_source.html#l00126]
Author
Parents
Loading