From ad42096a9d2605a238ce774d77e15bf6993231e3 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Mon, 22 Jan 2018 11:26:23 -0800 Subject: [PATCH] Avoid string_view::clear: String views are cleared using assignment from braced initializion, to avoid calling clear(). --- CHANGELOG.md | 1 + include/boost/beast/http/detail/rfc7230.hpp | 4 ++-- include/boost/beast/http/impl/fields.ipp | 16 ++++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61edd4ab..1447840a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Version 153: * Use make_error_code for setting an error_code from errc * Use boost::winapi::GetLastError() consistently * Update README.md for branches +* Avoid string_view::clear -------------------------------------------------------------------------------- diff --git a/include/boost/beast/http/detail/rfc7230.hpp b/include/boost/beast/http/detail/rfc7230.hpp index fdabc1a4..fac67905 100644 --- a/include/boost/beast/http/detail/rfc7230.hpp +++ b/include/boost/beast/http/detail/rfc7230.hpp @@ -352,8 +352,8 @@ increment() { it = first; }; - v.first.clear(); - v.second.clear(); + v.first = {}; + v.second = {}; detail::skip_ows(it, last); first = it; if(it == last) diff --git a/include/boost/beast/http/impl/fields.ipp b/include/boost/beast/http/impl/fields.ipp index d7d233a2..61dee1ca 100644 --- a/include/boost/beast/http/impl/fields.ipp +++ b/include/boost/beast/http/impl/fields.ipp @@ -364,8 +364,8 @@ basic_fields(basic_fields&& other) noexcept , method_(other.method_) , target_or_reason_(other.target_or_reason_) { - other.method_.clear(); - other.target_or_reason_.clear(); + other.method_ = {}; + other.target_or_reason_ = {}; } template @@ -1221,7 +1221,7 @@ realloc_string(string_view& dest, string_view s) { a.deallocate(const_cast( dest.data()), dest.size()); - dest.clear(); + dest = {}; } if(! s.empty()) { @@ -1249,7 +1249,7 @@ realloc_target( { a.deallocate(const_cast( dest.data()), dest.size()); - dest.clear(); + dest = {}; } if(! s.empty()) { @@ -1305,8 +1305,8 @@ move_assign(basic_fields& other, std::true_type) list_ = std::move(other.list_); method_ = other.method_; target_or_reason_ = other.target_or_reason_; - other.method_.clear(); - other.target_or_reason_.clear(); + other.method_ = {}; + other.target_or_reason_ = {}; this->member() = other.member(); } @@ -1328,8 +1328,8 @@ move_assign(basic_fields& other, std::false_type) list_ = std::move(other.list_); method_ = other.method_; target_or_reason_ = other.target_or_reason_; - other.method_.clear(); - other.target_or_reason_.clear(); + other.method_ = {}; + other.target_or_reason_ = {}; } }