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

Side by Side Diff: url/gurl.cc

Issue 1360533002: Cleanup: Initialize GURL by moving std::string (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass by value and then move it Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « url/gurl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "url/gurl.h" 5 #include "url/gurl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <ostream> 10 #include <ostream>
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 size_t canonical_spec_len, 94 size_t canonical_spec_len,
95 const url::Parsed& parsed, 95 const url::Parsed& parsed,
96 bool is_valid) 96 bool is_valid)
97 : spec_(canonical_spec, canonical_spec_len), 97 : spec_(canonical_spec, canonical_spec_len),
98 is_valid_(is_valid), 98 is_valid_(is_valid),
99 parsed_(parsed) { 99 parsed_(parsed) {
100 InitializeFromCanonicalSpec(); 100 InitializeFromCanonicalSpec();
101 } 101 }
102 102
103 GURL::GURL(std::string canonical_spec, const url::Parsed& parsed, bool is_valid) 103 GURL::GURL(std::string canonical_spec, const url::Parsed& parsed, bool is_valid)
104 : is_valid_(is_valid), 104 : spec_(std::move(canonical_spec)), is_valid_(is_valid), parsed_(parsed) {
105 parsed_(parsed) {
106 spec_.swap(canonical_spec);
107 InitializeFromCanonicalSpec(); 105 InitializeFromCanonicalSpec();
108 } 106 }
109 107
110 template<typename STR> 108 template<typename STR>
111 void GURL::InitCanonical(base::BasicStringPiece<STR> input_spec, 109 void GURL::InitCanonical(base::BasicStringPiece<STR> input_spec,
112 bool trim_path_end) { 110 bool trim_path_end) {
113 // Reserve enough room in the output for the input, plus some extra so that 111 // Reserve enough room in the output for the input, plus some extra so that
114 // we have room if we have to escape a few things without reallocating. 112 // we have room if we have to escape a few things without reallocating.
115 spec_.reserve(input_spec.size() + 32); 113 spec_.reserve(input_spec.size() + 32);
116 url::StdStringCanonOutput output(&spec_); 114 url::StdStringCanonOutput output(&spec_);
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 void GURL::Swap(GURL* other) { 535 void GURL::Swap(GURL* other) {
538 spec_.swap(other->spec_); 536 spec_.swap(other->spec_);
539 std::swap(is_valid_, other->is_valid_); 537 std::swap(is_valid_, other->is_valid_);
540 std::swap(parsed_, other->parsed_); 538 std::swap(parsed_, other->parsed_);
541 inner_url_.swap(other->inner_url_); 539 inner_url_.swap(other->inner_url_);
542 } 540 }
543 541
544 std::ostream& operator<<(std::ostream& out, const GURL& url) { 542 std::ostream& operator<<(std::ostream& out, const GURL& url) {
545 return out << url.possibly_invalid_spec(); 543 return out << url.possibly_invalid_spec();
546 } 544 }
OLDNEW
« no previous file with comments | « url/gurl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698