From 2836e738127b3a315977f1b9c51b30c6cfdf5dd2 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Thu, 29 Dec 2016 20:36:17 -1000 Subject: [PATCH] Add some reserve() calls --- lib/DirectoryEnumerator.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/DirectoryEnumerator.cpp b/lib/DirectoryEnumerator.cpp index 8a38ecc..ff6ead6 100644 --- a/lib/DirectoryEnumerator.cpp +++ b/lib/DirectoryEnumerator.cpp @@ -82,6 +82,7 @@ DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode, bool sort.emplace(std::make_pair(d.cFileName, Entry(std::move(fp), d.cFileName, 0, true))); } while (FindNextFileW(dir, &d)); + m_entries.reserve(sort.size()); if (reverse) for (auto it = sort.crbegin(); it != sort.crend(); ++it) m_entries.push_back(std::move(it->second)); @@ -117,6 +118,7 @@ DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode, bool sort.emplace(std::make_pair(st.st_size, Entry(std::move(fp), d.cFileName, st.st_size, false))); } while (FindNextFileW(dir, &d)); + m_entries.reserve(sort.size()); if (reverse) for (auto it = sort.crbegin(); it != sort.crend(); ++it) m_entries.push_back(std::move(it->second)); @@ -142,6 +144,7 @@ DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode, bool sort.emplace(std::make_pair(d.cFileName, Entry(std::move(fp), d.cFileName, st.st_size, false))); } while (FindNextFileW(dir, &d)); + m_entries.reserve(sort.size()); if (reverse) for (auto it = sort.crbegin(); it != sort.crend(); ++it) m_entries.push_back(std::move(it->second)); @@ -208,6 +211,7 @@ DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode, bool sort.emplace(std::make_pair(d->d_name, Entry(std::move(fp), d->d_name, 0, true))); } + m_entries.reserve(sort.size()); if (reverse) for (auto it = sort.crbegin(); it != sort.crend(); ++it) m_entries.push_back(std::move(it->second)); @@ -242,6 +246,7 @@ DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode, bool sort.emplace(std::make_pair(st.st_size, Entry(std::move(fp), d->d_name, st.st_size, false))); } + m_entries.reserve(sort.size()); if (reverse) for (auto it = sort.crbegin(); it != sort.crend(); ++it) m_entries.push_back(std::move(it->second)); @@ -267,6 +272,7 @@ DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode, bool sort.emplace(std::make_pair(d->d_name, Entry(std::move(fp), d->d_name, st.st_size, false))); } + m_entries.reserve(sort.size()); if (reverse) for (auto it = sort.crbegin(); it != sort.crend(); ++it) m_entries.push_back(std::move(it->second));