Browse Source

Improve string compare performance

yhirose 4 years ago
parent
commit
3d83cbb872
1 changed files with 3 additions and 3 deletions
  1. 3 3
      httplib.h

+ 3 - 3
httplib.h

@@ -4540,9 +4540,9 @@ inline bool Server::parse_request_line(const char *s, Request &req) {
     if (count != 3) { return false; }
     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; }
   if (methods.find(req.method) == methods.end()) { return false; }