Repository: nodejs/node
Pull request: http: optimize checkIsHttpToken for short strings

### Description
Optimize `checkIsHttpToken` performance by using a pre-computed lookup table for strings shorter than 10 characters instead of regex

### Benchmark Results
Shows significant performance improvements for short strings, with minimal impact on longer strings:
```
http/check_is_http_token.js n=1000000 key=':'                                                                         ***    188.25 %       ±1.05% ±1.41% ±1.86%
http/check_is_http_token.js n=1000000 key=':alternate-protocol'                                                       ***     -3.76 %       ±0.30% ±0.40% ±0.52%
http/check_is_http_token.js n=1000000 key='((((())))'                                                                 ***    188.71 %       ±1.01% ±1.35% ±1.79%
http/check_is_http_token.js n=1000000 key='@@'                                                                        ***    187.33 %       ±2.87% ±3.86% ±5.12%
http/check_is_http_token.js n=1000000 key='中文呢'                                                                       ***    108.16 %       ±0.91% ±1.23% ±1.61%
http/check_is_http_token.js n=1000000 key='Accept-Ranges'                                                             ***     -2.18 %       ±0.73% ±0.97% ±1.27%
http/check_is_http_token.js n=1000000 key='alt-svc'                                                                   ***     83.63 %       ±0.46% ±0.61% ±0.80%
http/check_is_http_token.js n=1000000 key='alternate-protocol:'                                                         *     -1.31 %       ±1.19% ±1.61% ±2.13%
http/check_is_http_token.js n=1000000 key='alternate-protocol'                                                        ***     -2.28 %       ±0.45% ±0.60% ±0.79%
http/check_is_http_token.js n=1000000 key='Cache-Control'                                                             ***     -2.47 %       ±0.34% ±0.46% ±0.60%
http/check_is_http_token.js n=1000000 key='Connection'                                                                ***     -1.86 %       ±0.52% ±0.69% ±0.91%
http/check_is_http_token.js n=1000000 key='Content-Encoding'                                                          ***     -2.23 %       ±0.65% ±0.86% ±1.12%
http/check_is_http_token.js n=1000000 key='content-length'                                                            ***     -2.61 %       ±0.98% ±1.32% ±1.74%
http/check_is_http_token.js n=1000000 key='Content-Location'                                                          ***     -2.24 %       ±0.44% ±0.58% ±0.76%
http/check_is_http_token.js n=1000000 key='content-type'                                                              ***     -1.34 %       ±0.37% ±0.49% ±0.64%
http/check_is_http_token.js n=1000000 key='Content-Type'                                                              ***     -1.45 %       ±0.31% ±0.42% ±0.54%
http/check_is_http_token.js n=1000000 key='date'                                                                      ***    145.58 %       ±0.77% ±1.03% ±1.34%
http/check_is_http_token.js n=1000000 key='ETag'                                                                      ***    145.77 %       ±0.56% ±0.75% ±0.98%
http/check_is_http_token.js n=1000000 key='Expires'                                                                   ***     83.44 %       ±0.45% ±0.60% ±0.78%
http/check_is_http_token.js n=1000000 key='Keep-Alive'                                                                ***     -1.36 %       ±0.41% ±0.55% ±0.71%
http/check_is_http_token.js n=1000000 key='Last-Modified'                                                             ***     -2.43 %       ±0.38% ±0.51% ±0.67%
http/check_is_http_token.js n=1000000 key='location'                                                                  ***     71.30 %       ±1.22% ±1.64% ±2.16%
http/check_is_http_token.js n=1000000 key='server'                                                                    ***     99.77 %       ±0.50% ±0.66% ±0.86%
http/check_is_http_token.js n=1000000 key='Server'                                                                    ***     99.28 %       ±0.53% ±0.71% ±0.92%
http/check_is_http_token.js n=1000000 key='status'                                                                    ***     98.86 %       ±0.57% ±0.76% ±0.99%
http/check_is_http_token.js n=1000000 key='TCN'                                                                       ***    224.62 %       ±1.33% ±1.78% ±2.34%
http/check_is_http_token.js n=1000000 key='Transfer-Encoding'                                                         ***     -1.98 %       ±0.48% ±0.64% ±0.84%
http/check_is_http_token.js n=1000000 key='Vary'                                                                      ***    145.11 %       ±0.85% ±1.13% ±1.49%
http/check_is_http_token.js n=1000000 key='version'                                                                   ***     83.58 %       ±0.46% ±0.61% ±0.80%
http/check_is_http_token.js n=1000000 key='x-frame-options'                                                           ***     -2.59 %       ±0.66% ±0.88% ±1.15%
http/check_is_http_token.js n=1000000 key='x-xss-protection'                                                          ***     -2.18 %       ±0.39% ±0.52% ±0.68%
```


Changed files:
filename: lib/_http_common.js
patch: @@ -24,6 +24,7 @@
 const {
   MathMin,
   Symbol,
+  Uint8Array,
 } = primordials;
 const { setImmediate } = require('timers');
 
@@ -205,7 +206,30 @@ function freeParser(parser, req, socket) {
   }
 }
 
+// Character code ranges for valid HTTP tokens
+// Valid chars: ^_`a-zA-Z-0-9!#$%&'*+.|~
+// Based on RFC 7230 Section 3.2.6 token definition
+// See https://tools.ietf.org/html/rfc7230#section-3.2.6
 const tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/;
+const validTokenChars = new Uint8Array([
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0-15
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31
+  0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, // 32-47 (!"#$%&'()*+,-./)
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 48-63 (0-9:;<=>?)
+  0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 64-79 (@A-O)
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, // 80-95 (P-Z[\]^_)
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 96-111 (`a-o)
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, // 112-127 (p-z{|}~)
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 128-143
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 144-159
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 160-175
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 176-191
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 192-207
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 208-223
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 224-239
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  // 240-255
+]);
+
 /**
  * Verifies that the given val is a valid HTTP token
  * per the rules defined in RFC 7230
@@ -214,7 +238,19 @@ const tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/;
  * @returns {boolean}
  */
 function checkIsHttpToken(val) {
-  return tokenRegExp.test(val);
+  if (val.length >= 10) {
+    return tokenRegExp.test(val);
+  }
+
+  if (val.length === 0) return false;
+
+  // Use lookup table for short strings, regex for longer ones
+  for (let i = 0; i < val.length; i++) {
+    if (!validTokenChars[val.charCodeAt(i)]) {
+      return false;
+    }
+  }
+  return true;
 }
 
 const headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/;