| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/scheme_host_port.h" | 5 #include "url/scheme_host_port.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 bool SchemeHostPort::operator<(const SchemeHostPort& other) const { | 195 bool SchemeHostPort::operator<(const SchemeHostPort& other) const { |
| 196 return std::tie(port_, scheme_, host_) < | 196 return std::tie(port_, scheme_, host_) < |
| 197 std::tie(other.port_, other.scheme_, other.host_); | 197 std::tie(other.port_, other.scheme_, other.host_); |
| 198 } | 198 } |
| 199 | 199 |
| 200 std::string SchemeHostPort::SerializeInternal(url::Parsed* parsed) const { | 200 std::string SchemeHostPort::SerializeInternal(url::Parsed* parsed) const { |
| 201 std::string result; | 201 std::string result; |
| 202 if (IsInvalid()) | 202 if (IsInvalid()) |
| 203 return result; | 203 return result; |
| 204 | 204 |
| 205 // Reserve enough space for the "normal" case of scheme://host/. |
| 206 result.reserve(scheme_.size() + host_.size() + 4); |
| 207 |
| 205 if (!scheme_.empty()) { | 208 if (!scheme_.empty()) { |
| 206 parsed->scheme = Component(0, scheme_.length()); | 209 parsed->scheme = Component(0, scheme_.length()); |
| 207 result.append(scheme_); | 210 result.append(scheme_); |
| 208 } | 211 } |
| 209 | 212 |
| 210 result.append(kStandardSchemeSeparator); | 213 result.append(kStandardSchemeSeparator); |
| 211 | 214 |
| 212 if (!host_.empty()) { | 215 if (!host_.empty()) { |
| 213 parsed->host = Component(result.length(), host_.length()); | 216 parsed->host = Component(result.length(), host_.length()); |
| 214 result.append(host_); | 217 result.append(host_); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 227 result.push_back(':'); | 230 result.push_back(':'); |
| 228 std::string port(base::UintToString(port_)); | 231 std::string port(base::UintToString(port_)); |
| 229 parsed->port = Component(result.length(), port.length()); | 232 parsed->port = Component(result.length(), port.length()); |
| 230 result.append(std::move(port)); | 233 result.append(std::move(port)); |
| 231 } | 234 } |
| 232 | 235 |
| 233 return result; | 236 return result; |
| 234 } | 237 } |
| 235 | 238 |
| 236 } // namespace url | 239 } // namespace url |
| OLD | NEW |