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

Unified Diff: url/gurl.h

Issue 1360533002: Cleanup: Initialize GURL by moving std::string (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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') | url/gurl.cc » ('J')
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 cdff0fd146bb814105602ea4f4dd16439c842129..dae87ff630ab243fe8f37d8246074836a850b96c 100644
--- a/url/gurl.h
+++ b/url/gurl.h
@@ -46,13 +46,17 @@ class URL_EXPORT GURL {
size_t canonical_spec_len,
const url::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::Parsed& parsed, bool is_valid);
+
+ // Notice that we can take the canonical_spec by rvalue reference so that we
+ // can convert from WebURL without copying the string. When we call this
ki.stfu 2015/09/21 05:55:55 (the original message is here: https://codereview.
+ // 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.
+ // The const reference version is used in unittests.
+ GURL(const std::string& canonical_spec,
+ const url::Parsed& parsed,
+ bool is_valid);
+ GURL(std::string&& canonical_spec, const url::Parsed& parsed,
danakj 2016/04/29 02:17:54 According to the google style guide the way to wri
ki.stfu 2016/05/25 16:53:33 I can't find a mention about this way in style gui
danakj 2016/05/25 19:59:37 https://google.github.io/styleguide/cppguide.html#
ki.stfu 2016/05/26 05:15:30 Doesn't it look like a moving "for perfect forward
+ bool is_valid) noexcept;
~GURL();
« no previous file with comments | « no previous file | url/gurl.cc » ('j') | url/gurl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698