summaryrefslogtreecommitdiffstats
path: root/url/gurl.cc
diff options
context:
space:
mode:
authorcjhopman@chromium.org <cjhopman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-24 21:56:33 +0000
committercjhopman@chromium.org <cjhopman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-24 21:56:33 +0000
commit8093a31b1f54b0f3f4248fa52e95fe80bcd8c1dd (patch)
treedb5dee29f6f183e33c8a38e6451d40083a28f51d /url/gurl.cc
parent33e01ed8635cc1ab08528ddbad8cb5e79cfce7c5 (diff)
downloadchromium_src-8093a31b1f54b0f3f4248fa52e95fe80bcd8c1dd.zip
chromium_src-8093a31b1f54b0f3f4248fa52e95fe80bcd8c1dd.tar.gz
chromium_src-8093a31b1f54b0f3f4248fa52e95fe80bcd8c1dd.tar.bz2
Use copy-swap idiom for GURL::operator=
All the work to correctly handle ownership and internal state of GURL is already done by the copy-constructor, destructor, and GURL::Swap. Repeating that work for GURL::operator= is just another place where we might get it wrong. BUG=309975 Review URL: https://codereview.chromium.org/30693010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230829 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'url/gurl.cc')
-rw-r--r--url/gurl.cc14
1 files changed, 2 insertions, 12 deletions
diff --git a/url/gurl.cc b/url/gurl.cc
index 60850e6..15de85a 100644
--- a/url/gurl.cc
+++ b/url/gurl.cc
@@ -167,18 +167,8 @@ void GURL::InitializeFromCanonicalSpec() {
GURL::~GURL() {
}
-GURL& GURL::operator=(const GURL& other) {
- if (&other == this)
- return *this;
-
- spec_ = other.spec_;
- is_valid_ = other.is_valid_;
- parsed_ = other.parsed_;
- inner_url_.reset(NULL);
- if (other.inner_url_)
- inner_url_.reset(new GURL(*other.inner_url_));
- // Valid filesystem urls should always have an inner_url_.
- DCHECK(!is_valid_ || !SchemeIsFileSystem() || inner_url_);
+GURL& GURL::operator=(GURL other) {
+ Swap(&other);
return *this;
}