Improve string compare performance

This commit is contained in:
yhirose 2021-07-12 23:51:56 -04:00
parent 8a803b30f6
commit 3d83cbb872

View file

@ -4540,9 +4540,9 @@ inline bool Server::parse_request_line(const char *s, Request &req) {
if (count != 3) { return false; }
}
const std::set<std::string> methods{"GET", "HEAD", "POST", "PUT",
"DELETE", "CONNECT", "OPTIONS", "TRACE",
"PATCH", "PRI"};
static const std::set<std::string> methods{
"GET", "HEAD", "POST", "PUT", "DELETE",
"CONNECT", "OPTIONS", "TRACE", "PATCH", "PRI"};
if (methods.find(req.method) == methods.end()) { return false; }