Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1196)

Unified Diff: third_party/WebKit/Source/wtf/text/WTFString.h

Issue 2007103003: Expand WTF::StringView's API to be more like StringPiece. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a lot of tests, fix a bunch of bugs. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/wtf/text/WTFString.h
diff --git a/third_party/WebKit/Source/wtf/text/WTFString.h b/third_party/WebKit/Source/wtf/text/WTFString.h
index 8d01437df9b2314a390c9d56513ad6af83386194..4b809023cf568ab24898a5bd38a0b0ebb586e7ce 100644
--- a/third_party/WebKit/Source/wtf/text/WTFString.h
+++ b/third_party/WebKit/Source/wtf/text/WTFString.h
@@ -343,9 +343,6 @@ public:
String left(unsigned len) const { return substring(0, len); }
String right(unsigned len) const { return substring(length() - len, len); }
- StringView createView() const { return StringView(impl()); }
- StringView createView(unsigned offset, unsigned length) const { return StringView(impl(), offset, length); }
-
// Returns a lowercase/uppercase version of the string
String lower() const;
String upper() const;
@@ -667,6 +664,13 @@ inline void String::prependTo(Vector<UChar, inlineCapacity>& result, unsigned po
}
}
+inline StringView::StringView(const String& string)
+ : StringView(string, 0, string.length()) {}
+inline StringView::StringView(const String& string, unsigned offset, unsigned length)
+ : StringView(string.impl(), offset, length) {}
+inline StringView::StringView(const String& string, unsigned offset)
+ : StringView(string.impl(), offset) {}
Yuta Kitamura 2016/05/27 04:47:41 Having inline definitions of StringView here looks
+
// StringHash is the default hash for String
template<typename T> struct DefaultHash;
template<> struct DefaultHash<String> {

Powered by Google App Engine
This is Rietveld 408576698