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

Side by Side Diff: url/gurl.cc

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 unified diff | Download patch
« url/gurl.h ('K') | « 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 #ifdef WIN32 5 #ifdef WIN32
6 #include <windows.h> 6 #include <windows.h>
7 #else 7 #else
8 #include <pthread.h> 8 #include <pthread.h>
9 #endif 9 #endif
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 GURL::GURL(const char* canonical_spec, 91 GURL::GURL(const char* canonical_spec,
92 size_t canonical_spec_len, 92 size_t canonical_spec_len,
93 const url::Parsed& parsed, 93 const url::Parsed& parsed,
94 bool is_valid) 94 bool is_valid)
95 : spec_(canonical_spec, canonical_spec_len), 95 : spec_(canonical_spec, canonical_spec_len),
96 is_valid_(is_valid), 96 is_valid_(is_valid),
97 parsed_(parsed) { 97 parsed_(parsed) {
98 InitializeFromCanonicalSpec(); 98 InitializeFromCanonicalSpec();
99 } 99 }
100 100
101 GURL::GURL(std::string canonical_spec, const url::Parsed& parsed, bool is_valid) 101 GURL::GURL(const std::string& canonical_spec,
102 : is_valid_(is_valid), 102 const url::Parsed& parsed,
103 bool is_valid)
104 : spec_(canonical_spec),
105 is_valid_(is_valid),
103 parsed_(parsed) { 106 parsed_(parsed) {
104 spec_.swap(canonical_spec);
105 InitializeFromCanonicalSpec(); 107 InitializeFromCanonicalSpec();
106 } 108 }
107 109
110 GURL::GURL(std::string&& canonical_spec,
111 const url::Parsed& parsed,
112 bool is_valid) noexcept
113 : spec_(std::move(canonical_spec)),
114 is_valid_(is_valid),
115 parsed_(parsed) {
116 InitializeFromCanonicalSpec();
117 }
118
108 template<typename STR> 119 template<typename STR>
109 void GURL::InitCanonical(const STR& input_spec, bool trim_path_end) { 120 void GURL::InitCanonical(const STR& input_spec, bool trim_path_end) {
110 // Reserve enough room in the output for the input, plus some extra so that 121 // Reserve enough room in the output for the input, plus some extra so that
111 // we have room if we have to escape a few things without reallocating. 122 // we have room if we have to escape a few things without reallocating.
112 spec_.reserve(input_spec.size() + 32); 123 spec_.reserve(input_spec.size() + 32);
113 url::StdStringCanonOutput output(&spec_); 124 url::StdStringCanonOutput output(&spec_);
114 is_valid_ = url::Canonicalize( 125 is_valid_ = url::Canonicalize(
115 input_spec.data(), static_cast<int>(input_spec.length()), trim_path_end, 126 input_spec.data(), static_cast<int>(input_spec.length()), trim_path_end,
116 NULL, &output, &parsed_); 127 NULL, &output, &parsed_);
117 128
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 void GURL::Swap(GURL* other) { 541 void GURL::Swap(GURL* other) {
531 spec_.swap(other->spec_); 542 spec_.swap(other->spec_);
532 std::swap(is_valid_, other->is_valid_); 543 std::swap(is_valid_, other->is_valid_);
533 std::swap(parsed_, other->parsed_); 544 std::swap(parsed_, other->parsed_);
534 inner_url_.swap(other->inner_url_); 545 inner_url_.swap(other->inner_url_);
535 } 546 }
536 547
537 std::ostream& operator<<(std::ostream& out, const GURL& url) { 548 std::ostream& operator<<(std::ostream& out, const GURL& url) {
538 return out << url.possibly_invalid_spec(); 549 return out << url.possibly_invalid_spec();
539 } 550 }
OLDNEW
« url/gurl.h ('K') | « url/gurl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698