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