Skip to content

Commit

Permalink
Add some reserve() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
jackoalan committed Dec 30, 2016
1 parent 512a8a1 commit 31a06ea
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/DirectoryEnumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode,
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));
Expand Down Expand Up @@ -108,6 +109,7 @@ DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode,
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));
Expand All @@ -133,6 +135,7 @@ DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode,
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));
Expand Down Expand Up @@ -199,6 +202,7 @@ DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode,
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));
Expand Down Expand Up @@ -233,6 +237,7 @@ DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode,
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));
Expand All @@ -258,6 +263,7 @@ DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode,
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));
Expand Down

0 comments on commit 31a06ea

Please sign in to comment.