Avoid unnecessarily dipping into C pointers in StripLeft
This can just be written with `find_first_not_of`. One less use of `string_view::data()`, which is a bit harder to reason about w.r.t. memory-safety.
PiperOrigin-RevId: 525836210
diff --git a/quiche/common/structured_headers.cc b/quiche/common/structured_headers.cc
index 1f8a12f..58aec62 100644
--- a/quiche/common/structured_headers.cc
+++ b/quiche/common/structured_headers.cc
@@ -53,11 +53,11 @@
// Removes characters in remove from the beginning of s.
void StripLeft(absl::string_view& s, absl::string_view remove) {
- size_t i = 0;
- while (i < s.size() && memchr(remove.data(), s[i], remove.size())) {
- ++i;
+ size_t i = s.find_first_not_of(remove);
+ if (i == absl::string_view::npos) {
+ i = s.size();
}
- if (i > 0) s.remove_prefix(i);
+ s.remove_prefix(i);
}
// Parser for (a subset of) Structured Headers for HTTP defined in [SH09] and