File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 192192 'src/spawn_sync.cc' ,
193193 'src/string_bytes.cc' ,
194194 'src/string_search.cc' ,
195- 'src/string_utils.cc' ,
196195 'src/stream_base.cc' ,
197196 'src/stream_wrap.cc' ,
198197 'src/tcp_wrap.cc' ,
629628 '<(OBJ_PATH)<(OBJ_SEPARATOR)util.<(OBJ_SUFFIX)' ,
630629 '<(OBJ_PATH)<(OBJ_SEPARATOR)string_bytes.<(OBJ_SUFFIX)' ,
631630 '<(OBJ_PATH)<(OBJ_SEPARATOR)string_search.<(OBJ_SUFFIX)' ,
632- '<(OBJ_PATH)<(OBJ_SEPARATOR)string_utils.<(OBJ_SUFFIX)' ,
633631 '<(OBJ_PATH)<(OBJ_SEPARATOR)stream_base.<(OBJ_SUFFIX)' ,
634632 '<(OBJ_PATH)<(OBJ_SEPARATOR)node_constants.<(OBJ_SUFFIX)' ,
635633 '<(OBJ_PATH)<(OBJ_SEPARATOR)node_revert.<(OBJ_SUFFIX)' ,
Original file line number Diff line number Diff line change @@ -131,10 +131,6 @@ enum url_error_cb_args {
131131 return str.length () >= 2 && name (str[0 ], str[1 ]); \
132132 }
133133
134- CHAR_TEST (8 , IsLowerCaseASCII, (ch >=' a' && ch <= ' z' ))
135-
136- CHAR_TEST (8 , IsLowerCaseASCII, (ch >=' a' && ch <= ' z' ))
137-
138134// https://infra.spec.whatwg.org/#ascii-tab-or-newline
139135CHAR_TEST (8 , IsASCIITabOrNewline, (ch == ' \t ' || ch == ' \n ' || ch == ' \r ' ))
140136
@@ -865,9 +861,7 @@ static url_host_type ParseHost(url_host* host,
865861 if (!stringutils::ContainsNonAscii (buf, strlen (buf))) {
866862 // Lowercase ASCII domains
867863 for (size_t n = 0 ; n < decoded.size (); n++) {
868- if (!IsLowerCaseASCII (decoded[n])) {
869- decoded[n] = ASCIILowercase (decoded[n]);
870- }
864+ decoded[n] = ASCIILowercase (decoded[n]);
871865 }
872866 } else {
873867 // Then we have to Unicode IDNA toASCII
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 22#ifndef SRC_STRING_UTILS_H_
33#define SRC_STRING_UTILS_H_
44
5- #include " env.h"
6- #include " env-inl.h"
7- #include " util.h"
5+ #include < cstddef>
6+ #include < cstdint>
87
98namespace node {
109namespace stringutils {
11- bool ContainsNonAscii (const char * src, size_t len);
10+ inline static bool contains_non_ascii_slow (const char * buf, size_t len) {
11+ for (size_t i = 0 ; i < len; ++i) {
12+ if (buf[i] & 0x80 )
13+ return true ;
14+ }
15+ return false ;
16+ }
17+
18+ inline bool ContainsNonAscii (const char * src, size_t len) {
19+ if (len < 16 ) {
20+ return contains_non_ascii_slow (src, len);
21+ }
22+
23+ const unsigned bytes_per_word = sizeof (uintptr_t );
24+ const unsigned align_mask = bytes_per_word - 1 ;
25+ const unsigned unaligned = reinterpret_cast <uintptr_t >(src) & align_mask;
26+
27+ if (unaligned > 0 ) {
28+ const unsigned n = bytes_per_word - unaligned;
29+ if (contains_non_ascii_slow (src, n))
30+ return true ;
31+ src += n;
32+ len -= n;
33+ }
34+
35+
36+ #if defined(_WIN64) || defined(_LP64)
37+ const uintptr_t mask = 0x8080808080808080ll ;
38+ #else
39+ const uintptr_t mask = 0x80808080l ;
40+ #endif
41+
42+ const uintptr_t * srcw = reinterpret_cast <const uintptr_t *>(src);
43+
44+ for (size_t i = 0 , n = len / bytes_per_word; i < n; ++i) {
45+ if (srcw[i] & mask)
46+ return true ;
47+ }
48+
49+ const unsigned remainder = len & align_mask;
50+ if (remainder > 0 ) {
51+ const size_t offset = len - remainder;
52+ if (contains_non_ascii_slow (src + offset, remainder))
53+ return true ;
54+ }
55+
56+ return false ;
57+ }
1258} // namespace stringutils
1359} // namespace node
1460
You can’t perform that action at this time.
0 commit comments