Skip to content

Commit

Permalink
Optimize url::can_parse: do not reserve memory for URL string
Browse files Browse the repository at this point in the history
  • Loading branch information
rmisev committed Jul 14, 2024
1 parent 99ad1ff commit 306e0ca
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions include/upa/url.h
Original file line number Diff line number Diff line change
Expand Up @@ -1599,9 +1599,11 @@ inline validation_errc url_parser::url_parse(url_serializer& urls, const CharT*
detail::do_remove_whitespace(first, last, buff_no_ws);
//TODO-WARN: validation error if removed

// reserve size (TODO: But what if `base` is used?)
const auto length = std::distance(first, last);
urls.reserve(length + 32);
if (urls.need_save()) {
// reserve size (TODO: But what if `base` is used?)
const auto length = std::distance(first, last);
urls.reserve(length + 32);
}

#ifdef UPA_URL_USE_ENCODING
const char* encoding = "UTF-8";
Expand Down

0 comments on commit 306e0ca

Please sign in to comment.