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

Side by Side Diff: third_party/WebKit/Source/platform/exported/URLConversion.cpp

Issue 1568073002: Reduce string copies in GURL creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "public/platform/URLConversion.h"
6
7 #include "public/platform/WebString.h"
8 #include "url/gurl.h"
9 #include "wtf/text/StringUTF8Adaptor.h"
10 #include "wtf/text/WTFString.h"
11
12 namespace blink {
13
14 GURL WebStringToGURL(const WebString& webString)
15 {
16 if (webString.isEmpty())
17 return GURL();
18
19 String str = webString;
20 if (str.is8Bit()) {
21 // Ensure the (possibly Latin-1) 8-bit string is UTF-8 for GURL.
22 StringUTF8Adaptor utf8(str);
23 return GURL(utf8.asStringPiece());
24 }
25
26 // GURL can consume UTF-16 directly.
27 return GURL(base::StringPiece16(str.characters16(), str.length()));
28 }
29
30 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/blink_platform.gyp ('k') | third_party/WebKit/public/blink_headers.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698