diff options
author | Kristian Monsen <kristianm@google.com> | 2010-05-21 16:53:46 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-05-25 10:24:15 +0100 |
commit | 6c2af9490927c3c5959b5cb07461b646f8b32f6c (patch) | |
tree | f7111b9b22befab472616c1d50ec94eb50f1ec8c /JavaScriptCore/wtf/text/WTFString.h | |
parent | a149172322a9067c14e8b474a53e63649aa17cad (diff) | |
download | external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.zip external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.tar.gz external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.tar.bz2 |
Merge WebKit at r59636: Initial merge by git
Change-Id: I59b289c4e6b18425f06ce41cc9d34c522515de91
Diffstat (limited to 'JavaScriptCore/wtf/text/WTFString.h')
-rw-r--r-- | JavaScriptCore/wtf/text/WTFString.h | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/JavaScriptCore/wtf/text/WTFString.h b/JavaScriptCore/wtf/text/WTFString.h index 7c3c2dd..d98621c 100644 --- a/JavaScriptCore/wtf/text/WTFString.h +++ b/JavaScriptCore/wtf/text/WTFString.h @@ -86,10 +86,25 @@ int reverseFind(const UChar*, size_t, UChar, int startPosition = -1); class String { public: String() { } // gives null string, distinguishable from an empty string - String(const UChar*, unsigned length); + String(const UChar* str, unsigned len) + { + if (!str) + return; + m_impl = StringImpl::create(str, len); + } + String(const char* str) + { + if (!str) + return; + m_impl = StringImpl::create(str); + } + String(const char* str, unsigned length) + { + if (!str) + return; + m_impl = StringImpl::create(str, length); + } String(const UChar*); // Specifically for null terminated UTF-16 - String(const char*); - String(const char*, unsigned length); String(StringImpl* i) : m_impl(i) { } String(PassRefPtr<StringImpl> i) : m_impl(i) { } String(RefPtr<StringImpl> i) : m_impl(i) { } @@ -103,11 +118,28 @@ public: static String adopt(StringBuffer& buffer) { return StringImpl::adopt(buffer); } static String adopt(Vector<UChar>& vector) { return StringImpl::adopt(vector); } - unsigned length() const; - const UChar* characters() const; + ALWAYS_INLINE unsigned length() const + { + if (!m_impl) + return 0; + return m_impl->length(); + } + + const UChar* characters() const + { + if (!m_impl) + return 0; + return m_impl->characters(); + } + const UChar* charactersWithNullTermination(); - UChar operator[](unsigned i) const; // if i >= length(), returns 0 + UChar operator[](unsigned i) const // if i >= length(), returns 0 + { + if (!m_impl || i >= m_impl->length()) + return 0; + return m_impl->characters()[i]; + } UChar32 characterStartingAt(unsigned) const; // Ditto. bool contains(UChar c) const { return find(c) != -1; } @@ -215,7 +247,7 @@ public: String threadsafeCopy() const; bool isNull() const { return !m_impl; } - bool isEmpty() const; + ALWAYS_INLINE bool isEmpty() const { return !m_impl || !m_impl->length(); } StringImpl* impl() const { return m_impl.get(); } |