diff options
author | Gregory Alfonso <gfunni234@gmail.com> | 2022-12-08 08:42:50 +0000 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-12-08 08:42:50 +0000 |
commit | 7f86bb0a713cbd2643c4ed5da9bd92d9b24eaa72 (patch) | |
tree | eb43de8c8e657559089e3c75a3ce42f8120cfc25 /llvm/lib/Support/VirtualFileSystem.cpp | |
parent | dd28e22953ad4094248d3e47d1f63893c1612d8c (diff) | |
download | llvm-7f86bb0a713cbd2643c4ed5da9bd92d9b24eaa72.zip llvm-7f86bb0a713cbd2643c4ed5da9bd92d9b24eaa72.tar.gz llvm-7f86bb0a713cbd2643c4ed5da9bd92d9b24eaa72.tar.bz2 |
[llvm] Call reserve before push_back in a loop
It is generally good practice, if you know how big the vector is going to be in the end, to reserve before continually calling "push_back" or "emplace_back"
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D139483
Diffstat (limited to 'llvm/lib/Support/VirtualFileSystem.cpp')
-rw-r--r-- | llvm/lib/Support/VirtualFileSystem.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index ace5827..ded5607 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -1506,6 +1506,7 @@ void RedirectingFileSystem::setRedirection( std::vector<StringRef> RedirectingFileSystem::getRoots() const { std::vector<StringRef> R; + R.reserve(Roots.size()); for (const auto &Root : Roots) R.push_back(Root->getName()); return R; |