зеркало из https://github.com/microsoft/STL.git
`<filesystem>`: Improve `symlink_status` performance (#5071)
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
This commit is contained in:
Родитель
7657fb0ffa
Коммит
c18bcea38f
|
@ -110,6 +110,7 @@ add_benchmark(adjacent_difference src/adjacent_difference.cpp)
|
|||
add_benchmark(bitset_from_string src/bitset_from_string.cpp)
|
||||
add_benchmark(bitset_to_string src/bitset_to_string.cpp)
|
||||
add_benchmark(efficient_nonlocking_print src/efficient_nonlocking_print.cpp)
|
||||
add_benchmark(filesystem src/filesystem.cpp)
|
||||
add_benchmark(find_and_count src/find_and_count.cpp)
|
||||
add_benchmark(find_first_of src/find_first_of.cpp)
|
||||
add_benchmark(iota src/iota.cpp)
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
|
||||
void symlink_status(benchmark::State& state) {
|
||||
const auto path = std::filesystem::temp_directory_path();
|
||||
|
||||
for (auto _ : state) {
|
||||
std::error_code ec;
|
||||
benchmark::DoNotOptimize(path);
|
||||
const auto status = std::filesystem::symlink_status(path, ec);
|
||||
benchmark::DoNotOptimize(status);
|
||||
benchmark::DoNotOptimize(ec);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(symlink_status);
|
||||
|
||||
BENCHMARK_MAIN();
|
|
@ -900,6 +900,13 @@ namespace {
|
|||
|
||||
_Flags &= ~_Get_file_attributes_data;
|
||||
}
|
||||
|
||||
if (!_STD _Bitmask_includes_any(_Attributes, __std_fs_file_attr::_Reparse_point)
|
||||
&& _STD _Bitmask_includes_any(_Flags, __std_fs_stats_flags::_Reparse_tag)) {
|
||||
// if reparse tag is requested by caller but the file is not a reparse point, set tag to _None
|
||||
_Stats->_Reparse_point_tag = __std_fs_reparse_tag::_None;
|
||||
_Flags &= ~__std_fs_stats_flags::_Reparse_tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче