forked from boostorg/beast
@@ -6,6 +6,7 @@ Version 58:
|
|||||||
* Specification for http read
|
* Specification for http read
|
||||||
* Avoid `std::string` in websocket
|
* Avoid `std::string` in websocket
|
||||||
* Fix basic_fields insert ordering
|
* Fix basic_fields insert ordering
|
||||||
|
* basic_fields::set optimization
|
||||||
|
|
||||||
API Changes:
|
API Changes:
|
||||||
|
|
||||||
|
@@ -115,7 +115,7 @@ public:
|
|||||||
operator()(value_type const& lhs, value_type const& rhs) const
|
operator()(value_type const& lhs, value_type const& rhs) const
|
||||||
{
|
{
|
||||||
return ci_less::operator()(
|
return ci_less::operator()(
|
||||||
lhs.name(), rhs.name());
|
lhs.name_string(), rhs.name_string());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -633,6 +633,9 @@ private:
|
|||||||
void
|
void
|
||||||
delete_element(value_type& e);
|
delete_element(value_type& e);
|
||||||
|
|
||||||
|
void
|
||||||
|
set_element(value_type& e);
|
||||||
|
|
||||||
void
|
void
|
||||||
realloc_string(string_view& dest, string_view s);
|
realloc_string(string_view& dest, string_view s);
|
||||||
|
|
||||||
|
@@ -507,8 +507,8 @@ basic_fields<Allocator>::
|
|||||||
set(field name, string_param const& value)
|
set(field name, string_param const& value)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(name != field::unknown);
|
BOOST_ASSERT(name != field::unknown);
|
||||||
erase(name);
|
set_element(new_element(name,
|
||||||
insert(name, value);
|
to_string(name), value.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
@@ -516,9 +516,9 @@ void
|
|||||||
basic_fields<Allocator>::
|
basic_fields<Allocator>::
|
||||||
set(string_view sname, string_param const& value)
|
set(string_view sname, string_param const& value)
|
||||||
{
|
{
|
||||||
auto const name = string_to_field(sname);
|
set_element(new_element(
|
||||||
erase(sname);
|
string_to_field(sname),
|
||||||
insert(name, sname, value);
|
sname, value.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
@@ -774,9 +774,9 @@ set_chunked_impl(bool v)
|
|||||||
BOOST_ASSERT(v);
|
BOOST_ASSERT(v);
|
||||||
auto it = find(field::transfer_encoding);
|
auto it = find(field::transfer_encoding);
|
||||||
if(it == end())
|
if(it == end())
|
||||||
this->insert(field::transfer_encoding, "chunked");
|
insert(field::transfer_encoding, "chunked");
|
||||||
else
|
else
|
||||||
this->set(field::transfer_encoding,
|
set(field::transfer_encoding,
|
||||||
it->value().to_string() + ", chunked");
|
it->value().to_string() + ", chunked");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -816,13 +816,43 @@ void
|
|||||||
basic_fields<Allocator>::
|
basic_fields<Allocator>::
|
||||||
delete_element(value_type& e)
|
delete_element(value_type& e)
|
||||||
{
|
{
|
||||||
auto const n = 1 +
|
auto const n = 1 + (e.off_ + e.len_ + 2 +
|
||||||
(e.off_ + e.len_ + 2 +
|
|
||||||
sizeof(value_type) - 1) / sizeof(value_type);
|
sizeof(value_type) - 1) / sizeof(value_type);
|
||||||
alloc_traits::destroy(alloc_, &e);
|
alloc_traits::destroy(alloc_, &e);
|
||||||
alloc_traits::deallocate(alloc_, &e, n);
|
alloc_traits::deallocate(alloc_, &e, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class Allocator>
|
||||||
|
void
|
||||||
|
basic_fields<Allocator>::
|
||||||
|
set_element(value_type& e)
|
||||||
|
{
|
||||||
|
auto it = set_.lower_bound(
|
||||||
|
e.name_string(), key_compare{});
|
||||||
|
if(it == set_.end() || ! beast::detail::ci_equal(
|
||||||
|
e.name_string(), it->name_string()))
|
||||||
|
{
|
||||||
|
set_.insert_before(it, e);
|
||||||
|
list_.push_back(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
auto next = it;
|
||||||
|
++next;
|
||||||
|
set_.erase(it);
|
||||||
|
list_.erase(list_.iterator_to(*it));
|
||||||
|
delete_element(*it);
|
||||||
|
it = next;
|
||||||
|
if(it == set_.end() ||
|
||||||
|
! beast::detail::ci_equal(
|
||||||
|
e.name_string(), it->name_string()))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
set_.insert_before(it, e);
|
||||||
|
list_.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
void
|
void
|
||||||
basic_fields<Allocator>::
|
basic_fields<Allocator>::
|
||||||
|
Reference in New Issue
Block a user