| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ec0d5be commit 463c645
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,13 @@ AsyncResource::AsyncResource(Isolate* isolate, | |||
| 16 | 16 | Local<Object> resource, | |
| 17 | 17 | const char* name, | |
| 18 | 18 | async_id trigger_async_id) | |
| 19 | + : AsyncResource( | ||
| 20 | + isolate, resource, std::string_view(name), trigger_async_id) {} | ||
| 21 | + | ||
| 22 | + AsyncResource::AsyncResource(Isolate* isolate, | ||
| 23 | + Local<Object> resource, | ||
| 24 | + std::string_view name, | ||
| 25 | + async_id trigger_async_id) | ||
| 19 | 26 | : env_(Environment::GetCurrent(isolate)), | |
| 20 | 27 | resource_(isolate, resource), | |
| 21 | 28 | context_frame_(isolate, async_context_frame::current(isolate)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -213,9 +213,18 @@ async_context EmitAsyncInit(Isolate* isolate, | |||
| 213 | 213 | Local<Object> resource, | |
| 214 | 214 | const char* name, | |
| 215 | 215 | async_id trigger_async_id) { | |
| 216 | + return EmitAsyncInit( | ||
| 217 | + isolate, resource, std::string_view(name), trigger_async_id); | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + async_context EmitAsyncInit(Isolate* isolate, | ||
| 221 | + Local<Object> resource, | ||
| 222 | + std::string_view name, | ||
| 223 | + async_id trigger_async_id) { | ||
| 216 | 224 | HandleScope handle_scope(isolate); | |
| 217 | 225 | Local<String> type = | |
| 218 | - String::NewFromUtf8(isolate, name, NewStringType::kInternalized) | ||
| 226 | + String::NewFromUtf8( | ||
| 227 | + isolate, name.data(), NewStringType::kInternalized, name.size()) | ||
| 219 | 228 | .ToLocalChecked(); | |
| 220 | 229 | return EmitAsyncInit(isolate, resource, type, trigger_async_id); | |
| 221 | 230 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -240,8 +240,8 @@ static void AsyncTaskScheduledWrapper(const FunctionCallbackInfo<Value>& args) { | |||
| 240 | 240 | ||
| 241 | 241 | CHECK(args[0]->IsString()); | |
| 242 | 242 | Local<String> task_name = args[0].As<String>(); | |
| 243 | - String::Value task_name_value(args.GetIsolate(), task_name); | ||
| 244 | - StringView task_name_view(*task_name_value, task_name_value.length()); | ||
| 243 | + TwoByteValue task_name_value(args.GetIsolate(), task_name); | ||
| 244 | + StringView task_name_view(task_name_value.out(), task_name_value.length()); | ||
| 245 | 245 | ||
| 246 | 246 | CHECK(args[1]->IsNumber()); | |
| 247 | 247 | int64_t task_id; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1458,6 +1458,10 @@ NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate, | |||
| 1458 | 1458 | v8::Local<v8::Object> resource, | |
| 1459 | 1459 | const char* name, | |
| 1460 | 1460 | async_id trigger_async_id = -1); | |
| 1461 | + NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate, | ||
| 1462 | + v8::Local<v8::Object> resource, | ||
| 1463 | + std::string_view name, | ||
| 1464 | + async_id trigger_async_id = -1); | ||
| 1461 | 1465 | ||
| 1462 | 1466 | NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate, | |
| 1463 | 1467 | v8::Local<v8::Object> resource, | |
@@ -1553,6 +1557,10 @@ class NODE_EXTERN AsyncResource { | |||
| 1553 | 1557 | v8::Local<v8::Object> resource, | |
| 1554 | 1558 | const char* name, | |
| 1555 | 1559 | async_id trigger_async_id = -1); | |
| 1560 | + AsyncResource(v8::Isolate* isolate, | ||
| 1561 | + v8::Local<v8::Object> resource, | ||
| 1562 | + std::string_view name, | ||
| 1563 | + async_id trigger_async_id = -1); | ||
| 1556 | 1564 | ||
| 1557 | 1565 | virtual ~AsyncResource(); | |
| 1558 | 1566 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -212,7 +212,7 @@ class ThreadSafeFunction : public node::AsyncResource { | |||
| 212 | 212 | napi_threadsafe_function_call_js call_js_cb_) | |
| 213 | 213 | : AsyncResource(env_->isolate, | |
| 214 | 214 | resource, | |
| 215 | - *v8::String::Utf8Value(env_->isolate, name)), | ||
| 215 | + node::Utf8Value(env_->isolate, name).ToStringView()), | ||
| 216 | 216 | thread_count(thread_count_), | |
| 217 | 217 | is_closing(false), | |
| 218 | 218 | dispatch_state(kDispatchIdle), | |
@@ -1176,7 +1176,7 @@ class Work : public node::AsyncResource, public node::ThreadPoolWork { | |||
| 1176 | 1176 | : AsyncResource( | |
| 1177 | 1177 | env->isolate, | |
| 1178 | 1178 | async_resource, | |
| 1179 | - *v8::String::Utf8Value(env->isolate, async_resource_name)), | ||
| 1179 | + node::Utf8Value(env->isolate, async_resource_name).ToStringView()), | ||
| 1180 | 1180 | ThreadPoolWork(env->node_env(), "node_api"), | |
| 1181 | 1181 | _env(env), | |
| 1182 | 1182 | _data(data), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -986,11 +986,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) { | |||
| 986 | 986 | size_t result = haystack_length; | |
| 987 | 987 | ||
| 988 | 988 | if (enc == UCS2) { | |
| 989 | - String::Value needle_value(isolate, needle); | ||
| 990 | - if (*needle_value == nullptr) { | ||
| 991 | - return args.GetReturnValue().Set(-1); | ||
| 992 | - } | ||
| 993 | - | ||
| 989 | + TwoByteValue needle_value(isolate, needle); | ||
| 994 | 990 | if (haystack_length < 2 || needle_value.length() < 1) { | |
| 995 | 991 | return args.GetReturnValue().Set(-1); | |
| 996 | 992 | } | |
@@ -1011,27 +1007,27 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) { | |||
| 1011 | 1007 | offset / 2, | |
| 1012 | 1008 | is_forward); | |
| 1013 | 1009 | } else { | |
| 1014 | - result = | ||
| 1015 | - nbytes::SearchString(reinterpret_cast<const uint16_t*>(haystack), | ||
| 1016 | - haystack_length / 2, | ||
| 1017 | - reinterpret_cast<const uint16_t*>(*needle_value), | ||
| 1018 | - needle_value.length(), | ||
| 1019 | - offset / 2, | ||
| 1020 | - is_forward); | ||
| 1010 | + result = nbytes::SearchString(reinterpret_cast<const uint16_t*>(haystack), | ||
| 1011 | + haystack_length / 2, | ||
| 1012 | + needle_value.out(), | ||
| 1013 | + needle_value.length(), | ||
| 1014 | + offset / 2, | ||
| 1015 | + is_forward); | ||
| 1021 | 1016 | } | |
| 1022 | 1017 | result *= 2; | |
| 1023 | 1018 | } else if (enc == UTF8) { | |
| 1024 | - String::Utf8Value needle_value(isolate, needle); | ||
| 1019 | + Utf8Value needle_value(isolate, needle); | ||
| 1025 | 1020 | if (*needle_value == nullptr) | |
| 1026 | 1021 | return args.GetReturnValue().Set(-1); | |
| 1027 | - | ||
| 1028 | - result = | ||
| 1029 | - nbytes::SearchString(reinterpret_cast<const uint8_t*>(haystack), | ||
| 1030 | - haystack_length, | ||
| 1031 | - reinterpret_cast<const uint8_t*>(*needle_value), | ||
| 1032 | - needle_length, | ||
| 1033 | - offset, | ||
| 1034 | - is_forward); | ||
| 1022 | + CHECK_GE(needle_length, needle_value.length()); | ||
| 1023 | + | ||
| 1024 | + result = nbytes::SearchString( | ||
| 1025 | + reinterpret_cast<const uint8_t*>(haystack), | ||
| 1026 | + haystack_length, | ||
| 1027 | + reinterpret_cast<const uint8_t*>(needle_value.out()), | ||
| 1028 | + needle_length, | ||
| 1029 | + offset, | ||
| 1030 | + is_forward); | ||
| 1035 | 1031 | } else if (enc == LATIN1) { | |
| 1036 | 1032 | uint8_t* needle_data = node::UncheckedMalloc<uint8_t>(needle_length); | |
| 1037 | 1033 | if (needle_data == nullptr) { | |
@@ -1316,10 +1312,10 @@ static void Btoa(const FunctionCallbackInfo<Value>& args) { | |||
| 1316 | 1312 | input->Length(), | |
| 1317 | 1313 | buffer.out()); | |
| 1318 | 1314 | } else { | |
| 1319 | - String::Value value(env->isolate(), input); | ||
| 1315 | + TwoByteValue value(env->isolate(), input); | ||
| 1320 | 1316 | MaybeStackBuffer<char> stack_buf(value.length()); | |
| 1321 | 1317 | size_t out_len = simdutf::convert_utf16_to_latin1( | |
| 1322 | - reinterpret_cast<const char16_t*>(*value), | ||
| 1318 | + reinterpret_cast<const char16_t*>(value.out()), | ||
| 1323 | 1319 | value.length(), | |
| 1324 | 1320 | stack_buf.out()); | |
| 1325 | 1321 | if (out_len == 0) { // error | |
@@ -1370,8 +1366,8 @@ static void Atob(const FunctionCallbackInfo<Value>& args) { | |||
| 1370 | 1366 | buffer.SetLength(expected_length); | |
| 1371 | 1367 | result = simdutf::base64_to_binary(data, input->Length(), buffer.out()); | |
| 1372 | 1368 | } else { // 16-bit case | |
| 1373 | - String::Value value(env->isolate(), input); | ||
| 1374 | - auto data = reinterpret_cast<const char16_t*>(*value); | ||
| 1369 | + TwoByteValue value(env->isolate(), input); | ||
| 1370 | + auto data = reinterpret_cast<const char16_t*>(value.out()); | ||
| 1375 | 1371 | size_t expected_length = | |
| 1376 | 1372 | simdutf::maximal_binary_length_from_base64(data, value.length()); | |
| 1377 | 1373 | buffer.AllocateSufficientStorage(expected_length); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1024,15 +1024,14 @@ void PerIsolateMessageListener(Local<Message> message, Local<Value> error) { | |||
| 1024 | 1024 | break; | |
| 1025 | 1025 | } | |
| 1026 | 1026 | Utf8Value filename(isolate, message->GetScriptOrigin().ResourceName()); | |
| 1027 | + Utf8Value msg(isolate, message->Get()); | ||
| 1027 | 1028 | // (filename):(line) (message) | |
| 1028 | - std::stringstream warning; | ||
| 1029 | - warning << *filename; | ||
| 1030 | - warning << ":"; | ||
| 1031 | - warning << message->GetLineNumber(env->context()).FromMaybe(-1); | ||
| 1032 | - warning << " "; | ||
| 1033 | - v8::String::Utf8Value msg(isolate, message->Get()); | ||
| 1034 | - warning << *msg; | ||
| 1035 | - USE(ProcessEmitWarningGeneric(env, warning.str().c_str(), "V8")); | ||
| 1029 | + std::string warning = | ||
| 1030 | + SPrintF("%s:%s %s", | ||
| 1031 | + filename, | ||
| 1032 | + message->GetLineNumber(env->context()).FromMaybe(-1), | ||
| 1033 | + msg); | ||
| 1034 | + USE(ProcessEmitWarningGeneric(env, warning, "V8")); | ||
| 1036 | 1035 | break; | |
| 1037 | 1036 | } | |
| 1038 | 1037 | case Isolate::MessageErrorLevel::kMessageError: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -455,8 +455,7 @@ static Maybe<std::string> ErrorToString(Isolate* isolate, | |||
| 455 | 455 | if (!maybe_str.ToLocal(&js_str)) { | |
| 456 | 456 | return Nothing<std::string>(); | |
| 457 | 457 | } | |
| 458 | - String::Utf8Value sv(isolate, js_str); | ||
| 459 | - return Just<>(std::string(*sv, sv.length())); | ||
| 458 | + return Just(Utf8Value(isolate, js_str).ToString()); | ||
| 460 | 459 | } | |
| 461 | 460 | ||
| 462 | 461 | static void PrintEmptyJavaScriptStack(JSONWriter* writer) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1508,8 +1508,7 @@ void DatabaseSync::CreateSession(const FunctionCallbackInfo<Value>& args) { | |||
| 1508 | 1508 | } | |
| 1509 | 1509 | ||
| 1510 | 1510 | if (table_value->IsString()) { | |
| 1511 | - String::Utf8Value str(env->isolate(), table_value); | ||
| 1512 | - table = *str; | ||
| 1511 | + table = Utf8Value(env->isolate(), table_value).ToString(); | ||
| 1513 | 1512 | } else { | |
| 1514 | 1513 | THROW_ERR_INVALID_ARG_TYPE( | |
| 1515 | 1514 | env->isolate(), "The \"options.table\" argument must be a string."); | |
@@ -1529,8 +1528,7 @@ void DatabaseSync::CreateSession(const FunctionCallbackInfo<Value>& args) { | |||
| 1529 | 1528 | return; | |
| 1530 | 1529 | } | |
| 1531 | 1530 | if (db_value->IsString()) { | |
| 1532 | - String::Utf8Value str(env->isolate(), db_value); | ||
| 1533 | - db_name = std::string(*str); | ||
| 1531 | + db_name = Utf8Value(env->isolate(), db_value).ToString(); | ||
| 1534 | 1532 | } else { | |
| 1535 | 1533 | THROW_ERR_INVALID_ARG_TYPE( | |
| 1536 | 1534 | env->isolate(), "The \"options.db\" argument must be a string."); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -237,8 +237,8 @@ void UpdateHeapCodeStatisticsBuffer(const FunctionCallbackInfo<Value>& args) { | |||
| 237 | 237 | ||
| 238 | 238 | void SetFlagsFromString(const FunctionCallbackInfo<Value>& args) { | |
| 239 | 239 | CHECK(args[0]->IsString()); | |
| 240 | - String::Utf8Value flags(args.GetIsolate(), args[0]); | ||
| 241 | - V8::SetFlagsFromString(*flags, static_cast<size_t>(flags.length())); | ||
| 240 | + Utf8Value flags(args.GetIsolate(), args[0]); | ||
| 241 | + V8::SetFlagsFromString(flags.out(), flags.length()); | ||
| 242 | 242 | } | |
| 243 | 243 | ||
| 244 | 244 | static void IsStringOneByteRepresentation( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments