refs #90, small optimizations

This commit is contained in:
Steffen Schuemann 2021-02-06 12:49:16 +01:00
parent ff271edfee
commit 75c647f327
2 changed files with 9 additions and 2 deletions

View File

@ -10,3 +10,8 @@ add_executable(fs_du du.cpp)
target_link_libraries(fs_du ghc_filesystem) target_link_libraries(fs_du ghc_filesystem)
AddExecutableWithStdFS(std_fs_du du.cpp) AddExecutableWithStdFS(std_fs_du du.cpp)
if(EXISTS "${PROJECT_SOURCE_DIR}/examples/benchmark.cpp")
add_executable(fs_benchmark benchmark.cpp)
set_property(TARGET fs_benchmark PROPERTY CXX_STANDARD 17)
target_link_libraries(fs_benchmark ghc_filesystem)
endif()

View File

@ -2850,7 +2850,7 @@ GHC_INLINE path path::parent_path() const
{ {
auto rootPathLen = _prefixLength + root_name_length() + (has_root_directory() ? 1 : 0); auto rootPathLen = _prefixLength + root_name_length() + (has_root_directory() ? 1 : 0);
if (rootPathLen < _path.length()) { if (rootPathLen < _path.length()) {
if (empty() || begin() == --end()) { if (empty()) {
return path(); return path();
} }
else { else {
@ -3068,7 +3068,9 @@ GHC_INLINE path::iterator::iterator(const path& p, const impl_string_type::const
, _root(p.has_root_directory() ? _first + static_cast<string_type::difference_type>(p._prefixLength + p.root_name_length()) : _last) , _root(p.has_root_directory() ? _first + static_cast<string_type::difference_type>(p._prefixLength + p.root_name_length()) : _last)
, _iter(pos) , _iter(pos)
{ {
if(pos != _last) {
updateCurrent(); updateCurrent();
}
} }
GHC_INLINE path::impl_string_type::const_iterator path::iterator::increment(const path::impl_string_type::const_iterator& pos) const GHC_INLINE path::impl_string_type::const_iterator path::iterator::increment(const path::impl_string_type::const_iterator& pos) const