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

Unified Diff: url/gurl.cc

Issue 2617173003: [url] Reserve output buffer for various URL parsing paths (Closed)
Patch Set: brettw review Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | url/url_canon.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/gurl.cc
diff --git a/url/gurl.cc b/url/gurl.cc
index c0e4a68c3fca08250c5fd21e46e234189d8c5c1f..43f30528593ffe1a0d0ecf4a6a9e69cca8b9a956 100644
--- a/url/gurl.cc
+++ b/url/gurl.cc
@@ -108,9 +108,6 @@ GURL::GURL(std::string canonical_spec, const url::Parsed& parsed, bool is_valid)
template<typename STR>
void GURL::InitCanonical(base::BasicStringPiece<STR> input_spec,
bool trim_path_end) {
- // Reserve enough room in the output for the input, plus some extra so that
- // we have room if we have to escape a few things without reallocating.
- spec_.reserve(input_spec.size() + 32);
url::StdStringCanonOutput output(&spec_);
is_valid_ = url::Canonicalize(
input_spec.data(), static_cast<int>(input_spec.length()), trim_path_end,
@@ -198,12 +195,7 @@ GURL GURL::Resolve(const std::string& relative) const {
return GURL();
GURL result;
-
- // Reserve enough room in the output for the input, plus some extra so that
- // we have room if we have to escape a few things without reallocating.
- result.spec_.reserve(spec_.size() + 32);
url::StdStringCanonOutput output(&result.spec_);
-
if (!url::ResolveRelative(spec_.data(), static_cast<int>(spec_.length()),
parsed_, relative.data(),
static_cast<int>(relative.length()),
@@ -229,12 +221,7 @@ GURL GURL::Resolve(const base::string16& relative) const {
return GURL();
GURL result;
-
- // Reserve enough room in the output for the input, plus some extra so that
- // we have room if we have to escape a few things without reallocating.
- result.spec_.reserve(spec_.size() + 32);
url::StdStringCanonOutput output(&result.spec_);
-
if (!url::ResolveRelative(spec_.data(), static_cast<int>(spec_.length()),
parsed_, relative.data(),
static_cast<int>(relative.length()),
@@ -262,11 +249,7 @@ GURL GURL::ReplaceComponents(
if (!is_valid_)
return GURL();
- // Reserve enough room in the output for the input, plus some extra so that
- // we have room if we have to escape a few things without reallocating.
- result.spec_.reserve(spec_.size() + 32);
url::StdStringCanonOutput output(&result.spec_);
-
result.is_valid_ = url::ReplaceComponents(
spec_.data(), static_cast<int>(spec_.length()), parsed_, replacements,
NULL, &output, &result.parsed_);
@@ -289,11 +272,7 @@ GURL GURL::ReplaceComponents(
if (!is_valid_)
return GURL();
- // Reserve enough room in the output for the input, plus some extra so that
- // we have room if we have to escape a few things without reallocating.
- result.spec_.reserve(spec_.size() + 32);
url::StdStringCanonOutput output(&result.spec_);
-
result.is_valid_ = url::ReplaceComponents(
spec_.data(), static_cast<int>(spec_.length()), parsed_, replacements,
NULL, &output, &result.parsed_);
« no previous file with comments | « no previous file | url/url_canon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698