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

Unified Diff: url/gurl.h

Issue 1349783006: Cleanup: Pass std::string as const reference if possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert third_party changes 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 | « ui/compositor/layer.cc ('k') | 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 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
Peter Kasting 2015/09/20 21:58:20 This sort of change is likely wrong. The old code
ki.stfu 2015/09/21 05:26:06 I'll copy and answer on it in https://codereview.c
+ // 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,
+ bool is_valid) noexcept;
~GURL();
« no previous file with comments | « ui/compositor/layer.cc ('k') | url/gurl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698