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

Unified Diff: url/gurl.h

Issue 20127002: Allow efficient WebURL -> GURL conversions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Elaborate comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | url/gurl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/gurl.h
diff --git a/url/gurl.h b/url/gurl.h
index 6e582499836b4bcc900983cf7c76348aa9329515..da5f73602e356ba0673cd1a7a1d5cf4b229285db 100644
--- a/url/gurl.h
+++ b/url/gurl.h
@@ -41,6 +41,14 @@ class URL_EXPORT GURL {
// information associated with the URL, which must be correct and consistent.
GURL(const char* canonical_spec, size_t canonical_spec_len,
const url_parse::Parsed& parsed, bool is_valid);
+ // Notice that we take the canonical_spec by value so that we can convert
+ // from WebURL without copying the string. When we call this constructor
+ // we pass in a temporary std::string, which lets the compiler skip the
+ // copy and just move the std::string into the function argument. In the
+ // implementation, we use swap to move the data into the GURL itself,
+ // which means we end up with zero copies.
+ GURL(std::string canonical_spec,
+ const url_parse::Parsed& parsed, bool is_valid);
~GURL();
@@ -335,6 +343,8 @@ class URL_EXPORT GURL {
}
private:
+ void InitializeFromCanonicalSpec();
+
// Returns the substring of the input identified by the given component.
std::string ComponentString(const url_parse::Component& comp) const {
if (comp.len <= 0)
« no previous file with comments | « no previous file | url/gurl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698