Improve performance of constructing filesystem::path from strings.

This patch fixes a performance bug when constructing or appending to a path
from a string or c-string. Previously we called 'push_back' to append every
single character. This caused multiple re-allocation and copies when at most
one reallocation is necessary. The new behavior is to simply call
`string::append` so it can correctly handle reallocation.

For large strings this change is a ~4x improvement. This also makes our path
faster to construct than libstdc++'s.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@285530 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/src/experimental/filesystem/path.cpp b/src/experimental/filesystem/path.cpp
index be970a8..546f3c4 100644
--- a/src/experimental/filesystem/path.cpp
+++ b/src/experimental/filesystem/path.cpp
@@ -42,8 +42,7 @@
 public:
   PathParser(string_view_t P, string_view_t E, unsigned char S)
       : Path(P), RawEntry(E), State(static_cast<ParserState>(S)) {
-    assert(S != 0);
-    assert(S != PS_BeforeBegin);
+    // S cannot be '0' or PS_BeforeBegin.
   }
 
   static PathParser CreateBegin(string_view_t P) noexcept {
@@ -94,7 +93,6 @@
 
     case PS_InFilenames: {
       PosPtr SepEnd = consumeSeparator(Start, End);
-      assert(SepEnd);
       if (SepEnd != End) {
         PosPtr TkEnd = consumeName(SepEnd, End);
         if (TkEnd)
@@ -131,7 +129,6 @@
                          SepEnd + 1, RStart + 1);
       } else {
         PosPtr TkStart = consumeName(RStart, REnd);
-        assert(TkStart);
         if (TkStart == REnd + 2 && consumeSeparator(TkStart, REnd) == REnd)
           return makeState(PS_InRootName, Path.data(), RStart + 1);
         else
@@ -192,14 +189,10 @@
 
 private:
   void makeState(ParserState NewState, PosPtr Start, PosPtr End) noexcept {
-    assert(NewState != PS_BeforeBegin && NewState != PS_AtEnd);
     State = NewState;
-    assert(Start < End);
-    assert(Start >= &Path.front() && End <= &Path.back() + 1);
     RawEntry = string_view_t(Start, End - Start);
   }
   void makeState(ParserState NewState) noexcept {
-    assert(NewState == PS_BeforeBegin || NewState == PS_AtEnd);
     State = NewState;
     RawEntry = {};
   }