@@ -244,28 +244,36 @@ http_parser_settings ConnectionImpl::settings_{
244
244
nullptr // on_chunk_complete
245
245
};
246
246
247
- ConnectionImpl::ConnectionImpl (Network::Connection& connection, http_parser_type type)
248
- : connection_(connection) {
249
- http_parser_init (&parser_, type);
250
- parser_.data = this ;
247
+ const ConnectionImpl::ToLowerTable ConnectionImpl::to_lower_table_;
248
+
249
+ ConnectionImpl::ToLowerTable::ToLowerTable () {
250
+ for (size_t c = 0 ; c < 256 ; c++) {
251
+ table_[c] = c;
252
+ if ((c >= ' A' ) && (c <= ' Z' )) {
253
+ table_[c] |= 0x20 ;
254
+ }
255
+ }
251
256
}
252
257
253
- static void toLowerCase (HeaderString& text) {
258
+ void ConnectionImpl::ToLowerTable:: toLowerCase (HeaderString& text) const {
254
259
char * buffer = text.buffer ();
255
260
uint32_t size = text.size ();
256
261
for (size_t i = 0 ; i < size; i++) {
257
- char c = buffer[i];
258
- if ((c >= ' A' ) && (c <= ' Z' )) {
259
- buffer[i] |= 0x20 ;
260
- }
262
+ buffer[i] = table_[static_cast <uint8_t >(buffer[i])];
261
263
}
262
264
}
263
265
266
+ ConnectionImpl::ConnectionImpl (Network::Connection& connection, http_parser_type type)
267
+ : connection_(connection) {
268
+ http_parser_init (&parser_, type);
269
+ parser_.data = this ;
270
+ }
271
+
264
272
void ConnectionImpl::completeLastHeader () {
265
273
conn_log_trace (" completed header: key={} value={}" , connection_, current_header_field_.c_str (),
266
274
current_header_value_.c_str ());
267
275
if (!current_header_field_.empty ()) {
268
- toLowerCase (current_header_field_);
276
+ to_lower_table_. toLowerCase (current_header_field_);
269
277
current_header_map_->addViaMove (std::move (current_header_field_),
270
278
std::move (current_header_value_));
271
279
}
0 commit comments