From 7f86bb0a713cbd2643c4ed5da9bd92d9b24eaa72 Mon Sep 17 00:00:00 2001 From: Gregory Alfonso Date: Thu, 8 Dec 2022 08:42:50 +0000 Subject: [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 --- llvm/lib/Support/VirtualFileSystem.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'llvm/lib/Support/VirtualFileSystem.cpp') diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index ace58270ef94..ded5607e0c53 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -1506,6 +1506,7 @@ void RedirectingFileSystem::setRedirection( std::vector RedirectingFileSystem::getRoots() const { std::vector R; + R.reserve(Roots.size()); for (const auto &Root : Roots) R.push_back(Root->getName()); return R; -- cgit v1.2.3