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));