Skip to content

Commit

Permalink
refs #90, small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
gulrak committed Feb 6, 2021
1 parent ff271ed commit 75c647f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ add_executable(fs_du du.cpp)
target_link_libraries(fs_du ghc_filesystem)
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()
6 changes: 4 additions & 2 deletions include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2850,7 +2850,7 @@ GHC_INLINE path path::parent_path() const
{
auto rootPathLen = _prefixLength + root_name_length() + (has_root_directory() ? 1 : 0);
if (rootPathLen < _path.length()) {
if (empty() || begin() == --end()) {
if (empty()) {
return path();
}
else {
Expand Down Expand Up @@ -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)
, _iter(pos)
{
updateCurrent();
if(pos != _last) {
updateCurrent();
}
}

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

0 comments on commit 75c647f

Please sign in to comment.