GeezerVison is showing github.com — src: create strings in `FIXED_ONE_BYTE_STRING` as internalized · nodejs/node@34dcb7d
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/util-inl.h +16-15Lines changed: 16 additions & 15 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -159,33 +159,34 @@ constexpr ContainerOfHelper<Inner, Outer> ContainerOf(Inner Outer::*field, | 159 | 159 |
| 160 | 160 | inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate, | 161 | 161 | const char* data, | 162 | | - int length) { | 163 | | - return v8::String::NewFromOneByte(isolate, | 164 | | - reinterpret_cast<const uint8_t*>(data), | 165 | | - v8::NewStringType::kNormal, | 166 | | - length).ToLocalChecked(); | | 162 | + int length, | | 163 | + v8::NewStringType type) { | | 164 | + return v8::String::NewFromOneByte( | | 165 | + isolate, reinterpret_cast<const uint8_t*>(data), type, length) | | 166 | + .ToLocalChecked(); | 167 | 167 | } | 168 | 168 |
| 169 | 169 | inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate, | 170 | 170 | const signed char* data, | 171 | | - int length) { | 172 | | - return v8::String::NewFromOneByte(isolate, | 173 | | - reinterpret_cast<const uint8_t*>(data), | 174 | | - v8::NewStringType::kNormal, | 175 | | - length).ToLocalChecked(); | | 171 | + int length, | | 172 | + v8::NewStringType type) { | | 173 | + return v8::String::NewFromOneByte( | | 174 | + isolate, reinterpret_cast<const uint8_t*>(data), type, length) | | 175 | + .ToLocalChecked(); | 176 | 176 | } | 177 | 177 |
| 178 | 178 | inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate, | 179 | 179 | const unsigned char* data, | 180 | | - int length) { | 181 | | - return v8::String::NewFromOneByte( | 182 | | - isolate, data, v8::NewStringType::kNormal, length) | | 180 | + int length, | | 181 | + v8::NewStringType type) { | | 182 | + return v8::String::NewFromOneByte(isolate, data, type, length) | 183 | 183 | .ToLocalChecked(); | 184 | 184 | } | 185 | 185 |
| 186 | 186 | inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate, | 187 | | - std::string_view str) { | 188 | | - return OneByteString(isolate, str.data(), str.size()); | | 187 | + std::string_view str, | | 188 | + v8::NewStringType type) { | | 189 | + return OneByteString(isolate, str.data(), str.size(), type); | 189 | 190 | } | 190 | 191 |
| 191 | 192 | char ToLower(char c) { | |
Collapse file Copy file name to clipboardExpand all lines: src/util.h +20-12Lines changed: 20 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -330,29 +330,37 @@ class KVStore { | 330 | 330 | }; | 331 | 331 |
| 332 | 332 | // Convenience wrapper around v8::String::NewFromOneByte(). | 333 | | -inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate, | 334 | | - const char* data, | 335 | | - int length = -1); | | 333 | +inline v8::Local<v8::String> OneByteString( | | 334 | + v8::Isolate* isolate, | | 335 | + const char* data, | | 336 | + int length = -1, | | 337 | + v8::NewStringType type = v8::NewStringType::kNormal); | 336 | 338 |
| 337 | 339 | // For the people that compile with -funsigned-char. | 338 | | -inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate, | 339 | | - const signed char* data, | 340 | | - int length = -1); | | 340 | +inline v8::Local<v8::String> OneByteString( | | 341 | + v8::Isolate* isolate, | | 342 | + const signed char* data, | | 343 | + int length = -1, | | 344 | + v8::NewStringType type = v8::NewStringType::kNormal); | 341 | 345 |
| 342 | | -inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate, | 343 | | - const unsigned char* data, | 344 | | - int length = -1); | | 346 | +inline v8::Local<v8::String> OneByteString( | | 347 | + v8::Isolate* isolate, | | 348 | + const unsigned char* data, | | 349 | + int length = -1, | | 350 | + v8::NewStringType type = v8::NewStringType::kNormal); | 345 | 351 |
| 346 | | -inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate, | 347 | | - std::string_view str); | | 352 | +inline v8::Local<v8::String> OneByteString( | | 353 | + v8::Isolate* isolate, | | 354 | + std::string_view str, | | 355 | + v8::NewStringType type = v8::NewStringType::kNormal); | 348 | 356 |
| 349 | 357 | // Used to be a macro, hence the uppercase name. | 350 | 358 | template <std::size_t N> | 351 | 359 | requires(N > 0) | 352 | 360 | inline v8::Local<v8::String> FIXED_ONE_BYTE_STRING(v8::Isolate* isolate, | 353 | 361 | const char (&data)[N]) { | 354 | 362 | CHECK_EQ(data[N - 1], '\0'); | 355 | | - return OneByteString(isolate, data, N - 1); | | 363 | + return OneByteString(isolate, data, N - 1, v8::NewStringType::kInternalized); | 356 | 364 | } | 357 | 365 |
| 358 | 366 | // tolower() is locale-sensitive. Use ToLower() instead. | |
|