| Index: third_party/WebKit/Source/wtf/text/StringConcatenate.h
|
| diff --git a/third_party/WebKit/Source/wtf/text/StringConcatenate.h b/third_party/WebKit/Source/wtf/text/StringConcatenate.h
|
| index 63a7c4e296292295007d7a15bff37fa10dac4e9e..fae93e668bebc700d1f9edad5814ad44cb6378ca 100644
|
| --- a/third_party/WebKit/Source/wtf/text/StringConcatenate.h
|
| +++ b/third_party/WebKit/Source/wtf/text/StringConcatenate.h
|
| @@ -50,21 +50,18 @@ template<>
|
| class StringTypeAdapter<char> {
|
| DISALLOW_NEW();
|
| public:
|
| - StringTypeAdapter<char>(char buffer)
|
| - : m_buffer(buffer)
|
| - {
|
| - }
|
| -
|
| - unsigned length() { return 1; }
|
| + explicit StringTypeAdapter<char>(char buffer)
|
| + : m_buffer(buffer) {}
|
|
|
| - bool is8Bit() { return true; }
|
| + unsigned length() const { return 1; }
|
| + bool is8Bit() const { return true; }
|
|
|
| - void writeTo(LChar* destination)
|
| + void writeTo(LChar* destination) const
|
| {
|
| *destination = m_buffer;
|
| }
|
|
|
| - void writeTo(UChar* destination) { *destination = m_buffer; }
|
| + void writeTo(UChar* destination) const { *destination = m_buffer; }
|
|
|
| private:
|
| unsigned char m_buffer;
|
| @@ -74,21 +71,18 @@ template<>
|
| class StringTypeAdapter<LChar> {
|
| DISALLOW_NEW();
|
| public:
|
| - StringTypeAdapter<LChar>(LChar buffer)
|
| - : m_buffer(buffer)
|
| - {
|
| - }
|
| -
|
| - unsigned length() { return 1; }
|
| + explicit StringTypeAdapter<LChar>(LChar buffer)
|
| + : m_buffer(buffer) {}
|
|
|
| - bool is8Bit() { return true; }
|
| + unsigned length() const { return 1; }
|
| + bool is8Bit() const { return true; }
|
|
|
| - void writeTo(LChar* destination)
|
| + void writeTo(LChar* destination) const
|
| {
|
| *destination = m_buffer;
|
| }
|
|
|
| - void writeTo(UChar* destination) { *destination = m_buffer; }
|
| + void writeTo(UChar* destination) const { *destination = m_buffer; }
|
|
|
| private:
|
| LChar m_buffer;
|
| @@ -99,21 +93,18 @@ class StringTypeAdapter<UChar> {
|
| DISALLOW_NEW();
|
| public:
|
| StringTypeAdapter<UChar>(UChar buffer)
|
| - : m_buffer(buffer)
|
| - {
|
| - }
|
| -
|
| - unsigned length() { return 1; }
|
| + : m_buffer(buffer) {}
|
|
|
| - bool is8Bit() { return m_buffer <= 0xff; }
|
| + unsigned length() const { return 1; }
|
| + bool is8Bit() const { return m_buffer <= 0xff; }
|
|
|
| - void writeTo(LChar* destination)
|
| + void writeTo(LChar* destination) const
|
| {
|
| ASSERT(is8Bit());
|
| *destination = static_cast<LChar>(m_buffer);
|
| }
|
|
|
| - void writeTo(UChar* destination) { *destination = m_buffer; }
|
| + void writeTo(UChar* destination) const { *destination = m_buffer; }
|
|
|
| private:
|
| UChar m_buffer;
|
| @@ -123,19 +114,15 @@ template<>
|
| class WTF_EXPORT StringTypeAdapter<char*> {
|
| DISALLOW_NEW();
|
| public:
|
| - StringTypeAdapter<char*>(char* buffer)
|
| + explicit StringTypeAdapter<char*>(char* buffer)
|
| : m_buffer(buffer)
|
| - , m_length(strlen(buffer))
|
| - {
|
| - }
|
| -
|
| - unsigned length() { return m_length; }
|
| + , m_length(strlen(buffer)) {}
|
|
|
| - bool is8Bit() { return true; }
|
| + unsigned length() const { return m_length; }
|
| + bool is8Bit() const { return true; }
|
|
|
| - void writeTo(LChar* destination);
|
| -
|
| - void writeTo(UChar* destination);
|
| + void writeTo(LChar* destination) const;
|
| + void writeTo(UChar* destination) const;
|
|
|
| private:
|
| const char* m_buffer;
|
| @@ -146,15 +133,13 @@ template<>
|
| class WTF_EXPORT StringTypeAdapter<LChar*> {
|
| DISALLOW_NEW();
|
| public:
|
| - StringTypeAdapter<LChar*>(LChar* buffer);
|
| -
|
| - unsigned length() { return m_length; }
|
| + explicit StringTypeAdapter<LChar*>(LChar* buffer);
|
|
|
| - bool is8Bit() { return true; }
|
| + unsigned length() const { return m_length; }
|
| + bool is8Bit() const { return true; }
|
|
|
| - void writeTo(LChar* destination);
|
| -
|
| - void writeTo(UChar* destination);
|
| + void writeTo(LChar* destination) const;
|
| + void writeTo(UChar* destination) const;
|
|
|
| private:
|
| const LChar* m_buffer;
|
| @@ -165,18 +150,17 @@ template<>
|
| class WTF_EXPORT StringTypeAdapter<const UChar*> {
|
| DISALLOW_NEW();
|
| public:
|
| - StringTypeAdapter(const UChar* buffer);
|
| -
|
| - unsigned length() { return m_length; }
|
| + explicit StringTypeAdapter(const UChar* buffer);
|
|
|
| - bool is8Bit() { return false; }
|
| + unsigned length() const { return m_length; }
|
| + bool is8Bit() const { return false; }
|
|
|
| - NO_RETURN_DUE_TO_CRASH void writeTo(LChar*)
|
| + NO_RETURN_DUE_TO_CRASH void writeTo(LChar*) const
|
| {
|
| RELEASE_ASSERT(false);
|
| }
|
|
|
| - void writeTo(UChar* destination);
|
| + void writeTo(UChar* destination) const;
|
|
|
| private:
|
| const UChar* m_buffer;
|
| @@ -187,15 +171,13 @@ template<>
|
| class WTF_EXPORT StringTypeAdapter<const char*> {
|
| DISALLOW_NEW();
|
| public:
|
| - StringTypeAdapter<const char*>(const char* buffer);
|
| + explicit StringTypeAdapter<const char*>(const char* buffer);
|
|
|
| - unsigned length() { return m_length; }
|
| + unsigned length() const { return m_length; }
|
| + bool is8Bit() const { return true; }
|
|
|
| - bool is8Bit() { return true; }
|
| -
|
| - void writeTo(LChar* destination);
|
| -
|
| - void writeTo(UChar* destination);
|
| + void writeTo(LChar* destination) const;
|
| + void writeTo(UChar* destination) const;
|
|
|
| private:
|
| const char* m_buffer;
|
| @@ -206,15 +188,13 @@ template<>
|
| class WTF_EXPORT StringTypeAdapter<const LChar*> {
|
| DISALLOW_NEW();
|
| public:
|
| - StringTypeAdapter<const LChar*>(const LChar* buffer);
|
| -
|
| - unsigned length() { return m_length; }
|
| -
|
| - bool is8Bit() { return true; }
|
| + explicit StringTypeAdapter<const LChar*>(const LChar* buffer);
|
|
|
| - void writeTo(LChar* destination);
|
| + unsigned length() const { return m_length; }
|
| + bool is8Bit() const { return true; }
|
|
|
| - void writeTo(UChar* destination);
|
| + void writeTo(LChar* destination) const;
|
| + void writeTo(UChar* destination) const;
|
|
|
| private:
|
| const LChar* m_buffer;
|
| @@ -222,63 +202,17 @@ private:
|
| };
|
|
|
| template<>
|
| -class WTF_EXPORT StringTypeAdapter<Vector<char>> {
|
| - DISALLOW_NEW();
|
| -public:
|
| - StringTypeAdapter<Vector<char>>(const Vector<char>& buffer)
|
| - : m_buffer(buffer)
|
| - {
|
| - }
|
| -
|
| - size_t length() { return m_buffer.size(); }
|
| -
|
| - bool is8Bit() { return true; }
|
| -
|
| - void writeTo(LChar* destination);
|
| -
|
| - void writeTo(UChar* destination);
|
| -
|
| -private:
|
| - const Vector<char>& m_buffer;
|
| -};
|
| -
|
| -template<>
|
| -class StringTypeAdapter<Vector<LChar>> {
|
| - DISALLOW_NEW();
|
| -public:
|
| - StringTypeAdapter<Vector<LChar>>(const Vector<LChar>& buffer)
|
| - : m_buffer(buffer)
|
| - {
|
| - }
|
| -
|
| - size_t length() { return m_buffer.size(); }
|
| -
|
| - bool is8Bit() { return true; }
|
| -
|
| - void writeTo(LChar* destination);
|
| -
|
| - void writeTo(UChar* destination);
|
| -
|
| -private:
|
| - const Vector<LChar>& m_buffer;
|
| -};
|
| -
|
| -template<>
|
| class WTF_EXPORT StringTypeAdapter<String> {
|
| DISALLOW_NEW();
|
| public:
|
| - StringTypeAdapter<String>(const String& string)
|
| - : m_buffer(string)
|
| - {
|
| - }
|
| -
|
| - unsigned length() { return m_buffer.length(); }
|
| + explicit StringTypeAdapter<String>(const String& string)
|
| + : m_buffer(string) {}
|
|
|
| - bool is8Bit() { return m_buffer.isNull() || m_buffer.is8Bit(); }
|
| + unsigned length() const { return m_buffer.length(); }
|
| + bool is8Bit() const { return m_buffer.isNull() || m_buffer.is8Bit(); }
|
|
|
| - void writeTo(LChar* destination);
|
| -
|
| - void writeTo(UChar* destination);
|
| + void writeTo(LChar* destination) const;
|
| + void writeTo(UChar* destination) const;
|
|
|
| private:
|
| const String& m_buffer;
|
| @@ -288,17 +222,14 @@ template<>
|
| class StringTypeAdapter<AtomicString> {
|
| DISALLOW_NEW();
|
| public:
|
| - StringTypeAdapter<AtomicString>(const AtomicString& string)
|
| - : m_adapter(string.getString())
|
| - {
|
| - }
|
| -
|
| - unsigned length() { return m_adapter.length(); }
|
| + explicit StringTypeAdapter<AtomicString>(const AtomicString& string)
|
| + : m_adapter(string.getString()) {}
|
|
|
| - bool is8Bit() { return m_adapter.is8Bit(); }
|
| + unsigned length() const { return m_adapter.length(); }
|
| + bool is8Bit() const { return m_adapter.is8Bit(); }
|
|
|
| - void writeTo(LChar* destination) { m_adapter.writeTo(destination); }
|
| - void writeTo(UChar* destination) { m_adapter.writeTo(destination); }
|
| + void writeTo(LChar* destination) const { m_adapter.writeTo(destination); }
|
| + void writeTo(UChar* destination) const { m_adapter.writeTo(destination); }
|
|
|
| private:
|
| StringTypeAdapter<String> m_adapter;
|
| @@ -313,11 +244,8 @@ inline void sumWithOverflow(unsigned& total, unsigned addend, bool& overflow)
|
| }
|
|
|
| template<typename StringType1, typename StringType2>
|
| -PassRefPtr<StringImpl> makeString(StringType1 string1, StringType2 string2)
|
| +PassRefPtr<StringImpl> makeString(const StringTypeAdapter<StringType1>& adapter1, const StringTypeAdapter<StringType2>& adapter2)
|
| {
|
| - StringTypeAdapter<StringType1> adapter1(string1);
|
| - StringTypeAdapter<StringType2> adapter2(string2);
|
| -
|
| bool overflow = false;
|
| unsigned length = adapter1.length();
|
| sumWithOverflow(length, adapter2.length(), overflow);
|
|
|