summaryrefslogtreecommitdiffstats
path: root/src/experimental/filesystem/path.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/experimental/filesystem/path.cpp')
-rw-r--r--src/experimental/filesystem/path.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/experimental/filesystem/path.cpp b/src/experimental/filesystem/path.cpp
index 96b81f7b0..f49d4cd2d 100644
--- a/src/experimental/filesystem/path.cpp
+++ b/src/experimental/filesystem/path.cpp
@@ -6,11 +6,9 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#undef NDEBUG
#include "experimental/filesystem"
#include "string_view"
#include "utility"
-#include "cassert"
namespace { namespace parser
{
@@ -58,13 +56,13 @@ public:
}
PosPtr peek() const noexcept {
- auto End = &Path.back() + 1;
auto TkEnd = getNextTokenStartPos();
+ auto End = getAfterBack();
return TkEnd == End ? nullptr : TkEnd;
}
void increment() noexcept {
- const PosPtr End = &Path.back() + 1;
+ const PosPtr End = getAfterBack();
const PosPtr Start = getNextTokenStartPos();
if (Start == End)
return makeState(PS_AtEnd);
@@ -111,9 +109,8 @@ public:
}
void decrement() noexcept {
- const PosPtr REnd = &Path.front() - 1;
+ const PosPtr REnd = getBeforeFront();
const PosPtr RStart = getCurrentTokenStartPos() - 1;
- assert(RStart != REnd);
switch (State) {
case PS_AtEnd: {
@@ -198,19 +195,27 @@ private:
RawEntry = {};
}
+ PosPtr getAfterBack() const noexcept {
+ return Path.data() + Path.size();
+ }
+
+ PosPtr getBeforeFront() const noexcept {
+ return Path.data() - 1;
+ }
+
/// \brief Return a pointer to the first character after the currently
/// lexed element.
PosPtr getNextTokenStartPos() const noexcept {
switch (State) {
case PS_BeforeBegin:
- return &Path.front();
+ return Path.data();
case PS_InRootName:
case PS_InRootDir:
case PS_InFilenames:
return &RawEntry.back() + 1;
case PS_InTrailingSep:
case PS_AtEnd:
- return &Path.back() + 1;
+ return getAfterBack();
}
_LIBCPP_UNREACHABLE();
}
@@ -322,7 +327,6 @@ string_view_t path::__root_path_raw() const
auto NextCh = PP.peek();
if (NextCh && *NextCh == '/') {
++PP;
- assert(PP.State == PathParser::PS_InRootDir);
return createView(__pn_.data(), &PP.RawEntry.back());
}
return PP.RawEntry;