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

Unified Diff: url/gurl.cc

Issue 30693010: Use copy-swap idiom for GURL::operator= (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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_unittest.cc » ('j') | url/gurl_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/gurl.cc
diff --git a/url/gurl.cc b/url/gurl.cc
index 7997d2230ddf96665be10b490a9bca8c0f452cb8..f4d8e56383ee97c20b939532531ae90e80a2aca2 100644
--- a/url/gurl.cc
+++ b/url/gurl.cc
@@ -169,18 +169,8 @@ GURL::~GURL() {
}
GURL& GURL::operator=(const GURL& other) {
- if (&other == this)
- return *this;
-
- spec_ = other.spec_;
- is_valid_ = other.is_valid_;
- parsed_ = other.parsed_;
- delete inner_url_;
- inner_url_ = NULL;
- if (other.inner_url_)
- inner_url_ = new GURL(*other.inner_url_);
- // Valid filesystem urls should always have an inner_url_.
- DCHECK(!is_valid_ || !SchemeIsFileSystem() || inner_url_);
+ GURL copy(other);
cjhopman 2013/10/22 17:14:01 This is less subtle than taking the thing by value
akalin 2013/10/22 17:56:41 http://gotw.ca/gotw/059.htm uses your way so I'm i
Jeffrey Yasskin 2013/10/22 18:02:54 Taking GURL by value saves a copy when the argumen
cjhopman 2013/10/22 19:03:44 Done.
+ Swap(&copy);
return *this;
}
« no previous file with comments | « no previous file | url/gurl_unittest.cc » ('j') | url/gurl_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698