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

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

Issue 2162863002: Add StringView constructor that takes a ref to save a branch in CSSTokenizerInputStream::rangeAt (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo. Created 4 years, 5 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/StringView.h
diff --git a/third_party/WebKit/Source/wtf/text/StringView.h b/third_party/WebKit/Source/wtf/text/StringView.h
index 6433c383e0bd17dd2a0022de3abf7697735fb371..a4ea6692240fd2a68a4f1b9e1034bff9ec30844a 100644
--- a/third_party/WebKit/Source/wtf/text/StringView.h
+++ b/third_party/WebKit/Source/wtf/text/StringView.h
@@ -43,6 +43,14 @@ public:
StringView(StringImpl*, unsigned offset);
StringView(StringImpl*, unsigned offset, unsigned length);
+ // From a non-null StringImpl, avoids the null check.
+ StringView(StringImpl& impl)
+ : m_impl(&impl)
+ , m_bytes(impl.bytes())
+ , m_length(impl.length()) {}
+ StringView(StringImpl&, unsigned offset);
+ StringView(StringImpl&, unsigned offset, unsigned length);
+
// From an String, implemented in String.h
inline StringView(const String&, unsigned offset, unsigned length);
inline StringView(const String&, unsigned offset);
@@ -175,6 +183,16 @@ inline StringView::StringView(StringImpl* impl, unsigned offset, unsigned length
impl ? set(*impl, offset, length) : clear();
}
+inline StringView::StringView(StringImpl& impl, unsigned offset)
+{
+ set(impl, offset, impl.length() - offset);
+}
+
+inline StringView::StringView(StringImpl& impl, unsigned offset, unsigned length)
+{
+ set(impl, offset, length);
+}
+
inline void StringView::clear()
{
m_length = 0;

Powered by Google App Engine
This is Rietveld 408576698