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

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

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 years, 11 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 40b0b94db853ac3594b537b74fae36ade0f6e816..b7bcb1a88a2e80f1dd8bade171e202668ac9c7c9 100644
--- a/third_party/WebKit/Source/wtf/text/StringView.h
+++ b/third_party/WebKit/Source/wtf/text/StringView.h
@@ -37,72 +37,57 @@
namespace WTF {
class WTF_EXPORT StringView {
- DISALLOW_NEW();
-public:
- StringView()
- : m_offset(0)
- , m_length(0)
- {
- }
-
- explicit StringView(PassRefPtr<StringImpl> impl)
- : m_impl(impl)
- , m_offset(0)
- , m_length(m_impl->length())
- {
- }
-
- StringView(PassRefPtr<StringImpl> impl, unsigned offset, unsigned length)
- : m_impl(impl)
- , m_offset(offset)
- , m_length(length)
- {
- ASSERT_WITH_SECURITY_IMPLICATION(offset + length <= m_impl->length());
- }
-
- void narrow(unsigned offset, unsigned length)
- {
- ASSERT_WITH_SECURITY_IMPLICATION(offset + length <= m_length);
- m_offset += offset;
- m_length = length;
- }
-
- bool isEmpty() const { return !m_length; }
- unsigned length() const { return m_length; }
-
- bool is8Bit() const { return m_impl->is8Bit(); }
-
- const LChar* characters8() const
- {
- if (!m_impl)
- return 0;
- ASSERT(is8Bit());
- return m_impl->characters8() + m_offset;
- }
-
- const UChar* characters16() const
- {
- if (!m_impl)
- return 0;
- ASSERT(!is8Bit());
- return m_impl->characters16() + m_offset;
- }
-
- PassRefPtr<StringImpl> toString() const
- {
- if (!m_impl)
- return m_impl;
- if (m_impl->is8Bit())
- return StringImpl::create(characters8(), m_length);
- return StringImpl::create(characters16(), m_length);
- }
-
-private:
- RefPtr<StringImpl> m_impl;
- unsigned m_offset;
- unsigned m_length;
+ DISALLOW_NEW();
+
+ public:
+ StringView() : m_offset(0), m_length(0) {}
+
+ explicit StringView(PassRefPtr<StringImpl> impl)
+ : m_impl(impl), m_offset(0), m_length(m_impl->length()) {}
+
+ StringView(PassRefPtr<StringImpl> impl, unsigned offset, unsigned length)
+ : m_impl(impl), m_offset(offset), m_length(length) {
+ ASSERT_WITH_SECURITY_IMPLICATION(offset + length <= m_impl->length());
+ }
+
+ void narrow(unsigned offset, unsigned length) {
+ ASSERT_WITH_SECURITY_IMPLICATION(offset + length <= m_length);
+ m_offset += offset;
+ m_length = length;
+ }
+
+ bool isEmpty() const { return !m_length; }
+ unsigned length() const { return m_length; }
+
+ bool is8Bit() const { return m_impl->is8Bit(); }
+
+ const LChar* characters8() const {
+ if (!m_impl)
+ return 0;
+ ASSERT(is8Bit());
+ return m_impl->characters8() + m_offset;
+ }
+
+ const UChar* characters16() const {
+ if (!m_impl)
+ return 0;
+ ASSERT(!is8Bit());
+ return m_impl->characters16() + m_offset;
+ }
+
+ PassRefPtr<StringImpl> toString() const {
+ if (!m_impl)
+ return m_impl;
+ if (m_impl->is8Bit())
+ return StringImpl::create(characters8(), m_length);
+ return StringImpl::create(characters16(), m_length);
+ }
+
+ private:
+ RefPtr<StringImpl> m_impl;
+ unsigned m_offset;
+ unsigned m_length;
};
-
}
using WTF::StringView;
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringUTF8Adaptor.h ('k') | third_party/WebKit/Source/wtf/text/TextCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698