Skip to content

Commit 75c647f

Browse files
committedFeb 6, 2021
refs #90, small optimizations
1 parent ff271ed commit 75c647f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
 

‎examples/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ add_executable(fs_du du.cpp)
1010
target_link_libraries(fs_du ghc_filesystem)
1111
AddExecutableWithStdFS(std_fs_du du.cpp)
1212

13+
if(EXISTS "${PROJECT_SOURCE_DIR}/examples/benchmark.cpp")
14+
add_executable(fs_benchmark benchmark.cpp)
15+
set_property(TARGET fs_benchmark PROPERTY CXX_STANDARD 17)
16+
target_link_libraries(fs_benchmark ghc_filesystem)
17+
endif()

‎include/ghc/filesystem.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -2850,7 +2850,7 @@ GHC_INLINE path path::parent_path() const
28502850
{
28512851
auto rootPathLen = _prefixLength + root_name_length() + (has_root_directory() ? 1 : 0);
28522852
if (rootPathLen < _path.length()) {
2853-
if (empty() || begin() == --end()) {
2853+
if (empty()) {
28542854
return path();
28552855
}
28562856
else {
@@ -3068,7 +3068,9 @@ GHC_INLINE path::iterator::iterator(const path& p, const impl_string_type::const
30683068
, _root(p.has_root_directory() ? _first + static_cast<string_type::difference_type>(p._prefixLength + p.root_name_length()) : _last)
30693069
, _iter(pos)
30703070
{
3071-
updateCurrent();
3071+
if(pos != _last) {
3072+
updateCurrent();
3073+
}
30723074
}
30733075

30743076
GHC_INLINE path::impl_string_type::const_iterator path::iterator::increment(const path::impl_string_type::const_iterator& pos) const

0 commit comments

Comments
 (0)
Please sign in to comment.