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

Side by Side Diff: Source/core/platform/chromium/support/WebString.cpp

Issue 20135002: Optimize WebURL -> GURL conversions (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "public/platform/WebString.h" 32 #include "public/platform/WebString.h"
33 33
34 #include "public/platform/WebCString.h" 34 #include "public/platform/WebCString.h"
35 #include "wtf/text/AtomicString.h" 35 #include "wtf/text/AtomicString.h"
36 #include "wtf/text/CString.h" 36 #include "wtf/text/CString.h"
37 #include "wtf/text/StringUTF8Adaptor.h"
37 #include "wtf/text/WTFString.h" 38 #include "wtf/text/WTFString.h"
38 39
39 namespace WebKit { 40 namespace WebKit {
40 41
41 void WebString::reset() 42 void WebString::reset()
42 { 43 {
43 m_private.reset(); 44 m_private.reset();
44 } 45 }
45 46
46 void WebString::assign(const WebString& other) 47 void WebString::assign(const WebString& other)
(...skipping 30 matching lines...) Expand all
77 const WebUChar* WebString::data16() const 78 const WebUChar* WebString::data16() const
78 { 79 {
79 return !m_private.isNull() && !is8Bit() ? m_private->characters16() : 0; 80 return !m_private.isNull() && !is8Bit() ? m_private->characters16() : 0;
80 } 81 }
81 82
82 WebCString WebString::utf8() const 83 WebCString WebString::utf8() const
83 { 84 {
84 return WTF::String(m_private.get()).utf8(); 85 return WTF::String(m_private.get()).utf8();
85 } 86 }
86 87
88 std::string WebString::toUTF8String() const
89 {
90 StringUTF8Adaptor utf8(m_private.get());
91 return std::string(utf8.data(), utf8.length());
92 }
93
87 WebString WebString::fromUTF8(const char* data, size_t length) 94 WebString WebString::fromUTF8(const char* data, size_t length)
88 { 95 {
89 return WTF::String::fromUTF8(data, length); 96 return WTF::String::fromUTF8(data, length);
90 } 97 }
91 98
92 WebString WebString::fromUTF8(const char* data) 99 WebString WebString::fromUTF8(const char* data)
93 { 100 {
94 return WTF::String::fromUTF8(data); 101 return WTF::String::fromUTF8(data);
95 } 102 }
96 103
97 bool WebString::equals(const WebString& s) const 104 bool WebString::equals(const WebString& s) const
98 { 105 {
99 return equal(m_private.get(), s.m_private.get()); 106 return equal(m_private.get(), s.m_private.get());
100 } 107 }
101 108
109 bool WebString::lessThan(const WebString& s) const
110 {
111 return m_private.get() < s.m_private.get();
112 }
113
102 WebString::WebString(const WTF::String& s) 114 WebString::WebString(const WTF::String& s)
103 { 115 {
104 m_private = s.impl(); 116 m_private = s.impl();
105 } 117 }
106 118
107 WebString& WebString::operator=(const WTF::String& s) 119 WebString& WebString::operator=(const WTF::String& s)
108 { 120 {
109 assign(s.impl()); 121 assign(s.impl());
110 return *this; 122 return *this;
111 } 123 }
(...skipping 18 matching lines...) Expand all
130 { 142 {
131 return WTF::AtomicString(m_private.get()); 143 return WTF::AtomicString(m_private.get());
132 } 144 }
133 145
134 void WebString::assign(WTF::StringImpl* p) 146 void WebString::assign(WTF::StringImpl* p)
135 { 147 {
136 m_private = p; 148 m_private = p;
137 } 149 }
138 150
139 } // namespace WebKit 151 } // namespace WebKit
OLDNEW
« no previous file with comments | « no previous file | Source/core/platform/chromium/support/WebURL.cpp » ('j') | public/platform/WebURL.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698