Commit 8089fb98 authored by agrieve's avatar agrieve Committed by Commit Bot

Make String16 consturctors non-inline to save binary size (150kb)

BUG=chromium:738469

Review-Url: https://codereview.chromium.org/2975133002
Cr-Commit-Position: refs/heads/master@{#46690}
parent ce19a620
...@@ -362,6 +362,41 @@ static inline void putUTF8Triple(char*& buffer, UChar ch) { ...@@ -362,6 +362,41 @@ static inline void putUTF8Triple(char*& buffer, UChar ch) {
} // namespace } // namespace
String16::String16() {}
String16::String16(const String16& other)
: m_impl(other.m_impl), hash_code(other.hash_code) {}
String16::String16(String16&& other)
: m_impl(std::move(other.m_impl)), hash_code(other.hash_code) {}
String16::String16(const UChar* characters, size_t size)
: m_impl(characters, size) {}
String16::String16(const UChar* characters) : m_impl(characters) {}
String16::String16(const char* characters)
: String16(characters, std::strlen(characters)) {}
String16::String16(const char* characters, size_t size) {
m_impl.resize(size);
for (size_t i = 0; i < size; ++i) m_impl[i] = characters[i];
}
String16::String16(const std::basic_string<UChar>& impl) : m_impl(impl) {}
String16& String16::operator=(const String16& other) {
m_impl = other.m_impl;
hash_code = other.hash_code;
return *this;
}
String16& String16::operator=(String16&& other) {
m_impl = std::move(other.m_impl);
hash_code = other.hash_code;
return *this;
}
// static // static
String16 String16::fromInteger(int number) { String16 String16::fromInteger(int number) {
char arr[50]; char arr[50];
......
...@@ -20,32 +20,17 @@ class String16 { ...@@ -20,32 +20,17 @@ class String16 {
public: public:
static const size_t kNotFound = static_cast<size_t>(-1); static const size_t kNotFound = static_cast<size_t>(-1);
String16() {} String16();
String16(const String16& other) String16(const String16& other);
: m_impl(other.m_impl), hash_code(other.hash_code) {} String16(String16&& other);
String16(String16&& other) String16(const UChar* characters, size_t size);
: m_impl(std::move(other.m_impl)), hash_code(other.hash_code) {} String16(const UChar* characters); // NOLINT(runtime/explicit)
String16(const UChar* characters, size_t size) : m_impl(characters, size) {} String16(const char* characters); // NOLINT(runtime/explicit)
String16(const UChar* characters) // NOLINT(runtime/explicit) String16(const char* characters, size_t size);
: m_impl(characters) {} explicit String16(const std::basic_string<UChar>& impl);
String16(const char* characters) // NOLINT(runtime/explicit)
: String16(characters, std::strlen(characters)) {} String16& operator=(const String16& other);
String16(const char* characters, size_t size) { String16& operator=(String16&& other);
m_impl.resize(size);
for (size_t i = 0; i < size; ++i) m_impl[i] = characters[i];
}
explicit String16(const std::basic_string<UChar>& impl) : m_impl(impl) {}
String16& operator=(const String16& other) {
m_impl = other.m_impl;
hash_code = other.hash_code;
return *this;
}
String16& operator=(String16&& other) {
m_impl = std::move(other.m_impl);
hash_code = other.hash_code;
return *this;
}
static String16 fromInteger(int); static String16 fromInteger(int);
static String16 fromInteger(size_t); static String16 fromInteger(size_t);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment