You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2018/03/28 19:20:36 UTC

[trafficserver] branch master updated: Update string_view to be compatible with gcc

This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 65ec38d  Update string_view to be compatible with gcc
65ec38d is described below

commit 65ec38ddd06510a7e42b4fc86311d57a4e8bbd57
Author: Bryan Call <bc...@apache.org>
AuthorDate: Tue Mar 27 17:03:02 2018 -0700

    Update string_view to be compatible with gcc
---
 lib/ts/TextView.h                     | 4 ++--
 lib/ts/string_view.h                  | 5 ++---
 lib/ts/unit-tests/test_string_view.cc | 2 +-
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/ts/TextView.h b/lib/ts/TextView.h
index 5554dd9..a779d87 100644
--- a/lib/ts/TextView.h
+++ b/lib/ts/TextView.h
@@ -663,7 +663,7 @@ TextView::split_prefix_at(size_t n)
   self_type zret; // default to empty return.
   if (n < this->size()) {
     zret = this->prefix(n);
-    this->remove_prefix(n + 1);
+    this->remove_prefix(std::min(n + 1, this->size()));
   }
   return zret;
 }
@@ -698,7 +698,7 @@ TextView::take_prefix_at(size_t n)
 {
   n              = std::min(n, this->size());
   self_type zret = this->prefix(n);
-  this->remove_prefix(n + 1);
+  this->remove_prefix(std::min(n + 1, this->size()));
   return zret;
 }
 
diff --git a/lib/ts/string_view.h b/lib/ts/string_view.h
index a702830..0503385 100644
--- a/lib/ts/string_view.h
+++ b/lib/ts/string_view.h
@@ -358,9 +358,8 @@ public:
 
   CONSTEXPR14 void remove_prefix(const size_type length) noexcept // strengthened
   {                                                               // chop off the beginning
-    auto tmp = std::min(length, m_size);
-    m_data += tmp;
-    m_size -= tmp;
+    m_data += length;
+    m_size -= length;
   }
 
   CONSTEXPR14 void remove_suffix(const size_type length) noexcept // strengthened
diff --git a/lib/ts/unit-tests/test_string_view.cc b/lib/ts/unit-tests/test_string_view.cc
index f5b240c..0eaf1fd 100644
--- a/lib/ts/unit-tests/test_string_view.cc
+++ b/lib/ts/unit-tests/test_string_view.cc
@@ -335,7 +335,7 @@ TEST_CASE("Modifier", "[string_view] [modifier]")
     sv.remove_prefix(3);
     REQUIRE(sv == "de");
 
-    sv.remove_prefix(100);
+    sv.remove_prefix(2);
     REQUIRE(sv == "");
   }
 

-- 
To stop receiving notification emails like this one, please contact
bcall@apache.org.