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

Side by Side Diff: third_party/WebKit/Source/wtf/text/WTFString.cpp

Issue 2658703005: Make WTFString constructor that takes const char* call strlen inline (Closed)
Patch Set: delegate ctor Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/text/WTFString.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights
4 * reserved. 4 * reserved.
5 * Copyright (C) 2007-2009 Torch Mobile, Inc. 5 * Copyright (C) 2007-2009 Torch Mobile, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // Construct a string with latin1 data. 81 // Construct a string with latin1 data.
82 String::String(const LChar* characters, unsigned length) 82 String::String(const LChar* characters, unsigned length)
83 : m_impl(characters ? StringImpl::create(characters, length) : nullptr) {} 83 : m_impl(characters ? StringImpl::create(characters, length) : nullptr) {}
84 84
85 String::String(const char* characters, unsigned length) 85 String::String(const char* characters, unsigned length)
86 : m_impl(characters ? StringImpl::create( 86 : m_impl(characters ? StringImpl::create(
87 reinterpret_cast<const LChar*>(characters), 87 reinterpret_cast<const LChar*>(characters),
88 length) 88 length)
89 : nullptr) {} 89 : nullptr) {}
90 90
91 // Construct a string with latin1 data, from a null-terminated source.
92 String::String(const LChar* characters)
93 : m_impl(characters ? StringImpl::create(characters) : nullptr) {}
94
95 String::String(const char* characters)
96 : m_impl(characters ? StringImpl::create(
97 reinterpret_cast<const LChar*>(characters))
98 : nullptr) {}
99
100 void String::append(const StringView& string) { 91 void String::append(const StringView& string) {
101 if (string.isEmpty()) 92 if (string.isEmpty())
102 return; 93 return;
103 if (!m_impl) { 94 if (!m_impl) {
104 m_impl = string.toString().releaseImpl(); 95 m_impl = string.toString().releaseImpl();
105 return; 96 return;
106 } 97 }
107 98
108 // FIXME: This is extremely inefficient. So much so that we might want to 99 // FIXME: This is extremely inefficient. So much so that we might want to
109 // take this out of String's API. We can make it better by optimizing the 100 // take this out of String's API. We can make it better by optimizing the
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 return out << '"'; 827 return out << '"';
837 } 828 }
838 829
839 #ifndef NDEBUG 830 #ifndef NDEBUG
840 void String::show() const { 831 void String::show() const {
841 dataLogF("%s\n", asciiDebug(impl()).data()); 832 dataLogF("%s\n", asciiDebug(impl()).data());
842 } 833 }
843 #endif 834 #endif
844 835
845 } // namespace WTF 836 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/WTFString.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698