diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-12 16:14:18 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-18 17:25:03 -0500 |
| commit | d082a91ad617808a6dd89ad9fdb9479524795520 (patch) | |
| tree | 1e0f10508d6779434f501638e647ef19d83eb46a /src/envfs.cpp | |
| parent | 7860e927a771d6a07d9b1905071bd389a0e64001 (diff) | |
faster getSubDirectory() for env::Directory, added lcname
instrumentation
Diffstat (limited to 'src/envfs.cpp')
| -rw-r--r-- | src/envfs.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/envfs.cpp b/src/envfs.cpp index 80749046..d7245f66 100644 --- a/src/envfs.cpp +++ b/src/envfs.cpp @@ -1,4 +1,5 @@ #include "envfs.h" +#include "env.h" #include "util.h" #include <utility.h> #include <log.h> @@ -160,6 +161,11 @@ public: m_handles.reserve(50'000); } + void shrink() + { + m_handles.shrink_to_fit(); + } + void add(HANDLE h) { m_handles.push_back(h); @@ -204,6 +210,15 @@ void setHandleCloserThreadCount(std::size_t n) g_handleClosers.setMax(n); } +void shrinkFs() +{ + g_handleClosers.join(); + + g_handleClosers.forEach([](auto&& t) { + t.shrink(); + }); +} + void forEachEntryImpl( void* cx, HandleCloserThread& hc, std::vector<std::unique_ptr<unsigned char[]>>& buffers, POBJECT_ATTRIBUTES poa, std::size_t depth, @@ -290,7 +305,6 @@ void forEachEntryImpl( forEachEntryImpl(cx, hc, buffers, &oa, depth+1, dirStartF, dirEndF, fileF); dirEndF(cx, toStringView(&oa)); } else { - //log::debug("{}{}", std::wstring((depth + 1) * 2, L' '), toString(&oa)); FILETIME ft; ft.dwLowDateTime = DirInfo->LastWriteTime.LowPart; ft.dwHighDateTime = DirInfo->LastWriteTime.HighPart; @@ -321,11 +335,10 @@ void forEachEntry( std::vector<std::unique_ptr<unsigned char[]>> buffers; if (!NtOpenFile) { - HMODULE m = ::LoadLibraryW(L"ntdll.dll"); - NtOpenFile = (NtOpenFile_type)::GetProcAddress(m, "NtOpenFile"); - NtQueryDirectoryFile = (NtQueryDirectoryFile_type)::GetProcAddress(m, "NtQueryDirectoryFile"); - NtClose = (NtClose_type)::GetProcAddress(m, "NtClose"); - ::FreeLibrary(m); + LibraryPtr m(::LoadLibraryW(L"ntdll.dll")); + NtOpenFile = (NtOpenFile_type)::GetProcAddress(m.get(), "NtOpenFile"); + NtQueryDirectoryFile = (NtQueryDirectoryFile_type)::GetProcAddress(m.get(), "NtQueryDirectoryFile"); + NtClose = (NtClose_type)::GetProcAddress(m.get(), "NtClose"); } const std::wstring ntpath = std::wstring(L"\\??\\") + path; @@ -358,7 +371,12 @@ Directory getFilesAndDirs(const std::wstring& path) env::forEachEntry(path, &cx, [](void* pcx, std::wstring_view path) { Context* cx = (Context*)pcx; - cx->current.top()->dirs.push_back({std::wstring(path.begin(), path.end())}); + + cx->current.top()->dirs.push_back({ + std::wstring(path.begin(), path.end()), + MOShared::ToLowerCopy(path) + }); + cx->current.push(&cx->current.top()->dirs.back()); }, |
