From 06290dc39f6ac33f5c74a82b4b635244914c5703 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 15 Jun 2017 06:59:54 -0700 Subject: [PATCH] Avoid std::string in websocket --- CHANGELOG.md | 1 + include/beast/websocket/detail/pmd_extension.hpp | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c74038c..a98f23b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Version 58: * Qualify size_t in message template * Reorganize examples * Specification for http read +* Avoid `std::string` in websocket API Changes: diff --git a/include/beast/websocket/detail/pmd_extension.hpp b/include/beast/websocket/detail/pmd_extension.hpp index a4f62079..75176b5b 100644 --- a/include/beast/websocket/detail/pmd_extension.hpp +++ b/include/beast/websocket/detail/pmd_extension.hpp @@ -200,14 +200,14 @@ template void pmd_write(Fields& fields, pmd_offer const& offer) { - std::string s; + static_string<512> s; s = "permessage-deflate"; if(offer.server_max_window_bits != 0) { if(offer.server_max_window_bits != -1) { s += "; server_max_window_bits="; - s += std::to_string( + s += to_static_string( offer.server_max_window_bits); } else @@ -220,7 +220,7 @@ pmd_write(Fields& fields, pmd_offer const& offer) if(offer.client_max_window_bits != -1) { s += "; client_max_window_bits="; - s += std::to_string( + s += to_static_string( offer.client_max_window_bits); } else @@ -256,7 +256,7 @@ pmd_negotiate( } config.accept = true; - std::string s = "permessage-deflate"; + static_string<512> s = "permessage-deflate"; config.server_no_context_takeover = offer.server_no_context_takeover || @@ -286,7 +286,7 @@ pmd_negotiate( config.server_max_window_bits = 9; s += "; server_max_window_bits="; - s += std::to_string( + s += to_static_string( config.server_max_window_bits); } @@ -299,7 +299,7 @@ pmd_negotiate( if(config.client_max_window_bits < 15) { s += "; client_max_window_bits="; - s += std::to_string( + s += to_static_string( config.client_max_window_bits); } break; @@ -324,7 +324,7 @@ pmd_negotiate( o.client_max_window_bits, offer.client_max_window_bits); s += "; client_max_window_bits="; - s += std::to_string( + s += to_static_string( config.client_max_window_bits); break; }