diff options
author | cjhopman@chromium.org <cjhopman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-24 21:56:33 +0000 |
---|---|---|
committer | cjhopman@chromium.org <cjhopman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-24 21:56:33 +0000 |
commit | 8093a31b1f54b0f3f4248fa52e95fe80bcd8c1dd (patch) | |
tree | db5dee29f6f183e33c8a38e6451d40083a28f51d /url/gurl.cc | |
parent | 33e01ed8635cc1ab08528ddbad8cb5e79cfce7c5 (diff) | |
download | chromium_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.cc | 14 |
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; } |