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

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& webStr)
esprehn 2016/01/14 01:47:59 webString
15 {
16 WTF::String str = webStr;
esprehn 2016/01/14 01:47:59 no need for WTF:: prefix. also wtfString, don't a
17 if (str.is8Bit()) {
18 // Ensure the (possibly Latin-1) 8-bit string is UTF-8 for GURL.
19 WTF::StringUTF8Adaptor utf8(str);
20 return GURL(utf8.asStringPiece());
esprehn 2016/01/14 01:47:59 Note that this isn't safe unless the GURL copies t
21 }
22
23 // GURL can consume UTF-16 directly.
24 return GURL(base::StringPiece16(str.characters16(), str.length()));
25 }
26
27 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698