GeezerVison is showing github.com — src: update repeated use strings to env · nodejs/node@a293dbf
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/crypto/crypto_context.cc +3-6Lines changed: 3 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2255,12 +2255,9 @@ void SecureContext::GetCertificateCompressionAlgorithms( | 2255 | 2255 | Environment* env = Environment::GetCurrent(args); | 2256 | 2256 | LocalVector<Value> algs(env->isolate()); | 2257 | 2257 | #ifdef NODE_OPENSSL_HAS_CERT_COMP | 2258 | | - if (BIO_f_zlib() != nullptr) | 2259 | | - algs.push_back(FIXED_ONE_BYTE_STRING(env->isolate(), "zlib")); | 2260 | | - if (BIO_f_brotli() != nullptr) | 2261 | | - algs.push_back(FIXED_ONE_BYTE_STRING(env->isolate(), "brotli")); | 2262 | | - if (BIO_f_zstd() != nullptr) | 2263 | | - algs.push_back(FIXED_ONE_BYTE_STRING(env->isolate(), "zstd")); | | 2258 | + if (BIO_f_zlib() != nullptr) algs.push_back(env->zlib_string()); | | 2259 | + if (BIO_f_brotli() != nullptr) algs.push_back(env->brotli_string()); | | 2260 | + if (BIO_f_zstd() != nullptr) algs.push_back(env->zstd_string()); | 2264 | 2261 | #endif | 2265 | 2262 | args.GetReturnValue().Set( | 2266 | 2263 | Array::New(env->isolate(), algs.data(), algs.size())); | |
Collapse file Copy file name to clipboardExpand all lines: src/crypto/crypto_ec.cc +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -520,16 +520,16 @@ bool ExportJWKEcKey(Environment* env, | 520 | 520 | const int nid = EC_GROUP_get_curve_name(group); | 521 | 521 | switch (nid) { | 522 | 522 | case NID_X9_62_prime256v1: | 523 | | - crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-256"); | | 523 | + crv_name = env->p256_string(); | 524 | 524 | break; | 525 | 525 | case NID_secp256k1: | 526 | | - crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "secp256k1"); | | 526 | + crv_name = env->secp256k1_string(); | 527 | 527 | break; | 528 | 528 | case NID_secp384r1: | 529 | | - crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-384"); | | 529 | + crv_name = env->p384_string(); | 530 | 530 | break; | 531 | 531 | case NID_secp521r1: | 532 | | - crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-521"); | | 532 | + crv_name = env->p521_string(); | 533 | 533 | break; | 534 | 534 | default: { | 535 | 535 | THROW_ERR_CRYPTO_JWK_UNSUPPORTED_CURVE( | |
Collapse file Copy file name to clipboardExpand all lines: src/crypto/crypto_keys.cc +10-16Lines changed: 10 additions & 16 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1796,8 +1796,7 @@ BaseObjectPtr<BaseObject> NativeKeyObject::KeyObjectTransferData::Deserialize( | 1796 | 1796 | return {}; | 1797 | 1797 |
| 1798 | 1798 | Local<Function> key_ctor; | 1799 | | - Local<Value> arg = FIXED_ONE_BYTE_STRING(env->isolate(), | 1800 | | - "internal/crypto/keys"); | | 1799 | + Local<Value> arg = env->internal_crypto_keys_string(); | 1801 | 1800 | if (env->builtin_module_require() | 1802 | 1801 | ->Call(context, Null(env->isolate()), 1, &arg) | 1803 | 1802 | .IsEmpty()) { | @@ -1875,7 +1874,7 @@ MaybeLocal<Value> NativeCryptoKey::Create(Environment* env, | 1875 | 1874 | if (!KeyObjectHandle::Create(env, data).ToLocal(&handle)) return {}; | 1876 | 1875 |
| 1877 | 1876 | if (env->crypto_internal_cryptokey_constructor().IsEmpty()) { | 1878 | | - Local<Value> arg = FIXED_ONE_BYTE_STRING(isolate, "internal/crypto/keys"); | | 1877 | + Local<Value> arg = env->internal_crypto_keys_string(); | 1879 | 1878 | if (env->builtin_module_require() | 1880 | 1879 | ->Call(context, Null(isolate), 1, &arg) | 1881 | 1880 | .IsEmpty()) { | @@ -2017,31 +2016,28 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead( | 2017 | 2016 | } | 2018 | 2017 | CHECK(bundle_v->IsObject()); | 2019 | 2018 | Local<Object> bundle = bundle_v.As<Object>(); | 2020 | | - Isolate* isolate = env()->isolate(); | 2021 | 2019 | Local<Object> obj = object(); | 2022 | 2020 |
| 2023 | 2021 | // The partially-initialized object produced by | 2024 | 2022 | // CryptoKeyTransferData::Deserialize should not have algorithm set yet. | 2025 | 2023 | CHECK(obj->GetInternalField(kAlgorithmField).As<Value>()->IsUndefined()); | 2026 | 2024 |
| 2027 | 2025 | Local<Value> algorithm_v; | 2028 | | - if (!bundle->Get(context, FIXED_ONE_BYTE_STRING(isolate, "algorithm")) | 2029 | | - .ToLocal(&algorithm_v)) { | | 2026 | + if (!bundle->Get(context, env()->algorithm_string()).ToLocal(&algorithm_v)) { | 2030 | 2027 | return Nothing<void>(); | 2031 | 2028 | } | 2032 | 2029 | CHECK(algorithm_v->IsObject()); | 2033 | 2030 | obj->SetInternalField(kAlgorithmField, algorithm_v); | 2034 | 2031 |
| 2035 | 2032 | Local<Value> usages_v; | 2036 | | - if (!bundle->Get(context, FIXED_ONE_BYTE_STRING(isolate, "usages")) | 2037 | | - .ToLocal(&usages_v)) { | | 2033 | + if (!bundle->Get(context, env()->usages_string()).ToLocal(&usages_v)) { | 2038 | 2034 | return Nothing<void>(); | 2039 | 2035 | } | 2040 | 2036 | CHECK(usages_v->IsUint32()); | 2041 | 2037 | usages_mask_ = usages_v.As<Uint32>()->Value(); | 2042 | 2038 |
| 2043 | 2039 | Local<Value> extractable_v; | 2044 | | - if (!bundle->Get(context, FIXED_ONE_BYTE_STRING(isolate, "extractable")) | | 2040 | + if (!bundle->Get(context, env()->extractable_string()) | 2045 | 2041 | .ToLocal(&extractable_v)) { | 2046 | 2042 | return Nothing<void>(); | 2047 | 2043 | } | @@ -2054,21 +2050,19 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead( | 2054 | 2050 | Maybe<bool> NativeCryptoKey::CryptoKeyTransferData::FinalizeTransferWrite( | 2055 | 2051 | Local<Context> context, v8::ValueSerializer* serializer) { | 2056 | 2052 | Isolate* isolate = Isolate::GetCurrent(); | | 2053 | + Environment* env = Environment::GetCurrent(isolate); | 2057 | 2054 | CHECK(!algorithm_.IsEmpty()); | 2058 | 2055 | Local<Object> bundle = Object::New(isolate); | 2059 | 2056 | Local<Value> algorithm_v = PersistentToLocal::Strong(algorithm_); | 2060 | | - if (bundle | 2061 | | - ->Set( | 2062 | | - context, FIXED_ONE_BYTE_STRING(isolate, "algorithm"), algorithm_v) | 2063 | | - .IsNothing() || | | 2057 | + if (bundle->Set(context, env->algorithm_string(), algorithm_v).IsNothing() || | 2064 | 2058 | bundle | 2065 | 2059 | ->Set(context, | 2066 | | - FIXED_ONE_BYTE_STRING(isolate, "usages"), | | 2060 | + env->usages_string(), | 2067 | 2061 | Uint32::NewFromUnsigned(isolate, usages_mask_)) | 2068 | 2062 | .IsNothing() || | 2069 | 2063 | bundle | 2070 | 2064 | ->Set(context, | 2071 | | - FIXED_ONE_BYTE_STRING(isolate, "extractable"), | | 2065 | + env->extractable_string(), | 2072 | 2066 | v8::Boolean::New(isolate, extractable_)) | 2073 | 2067 | .IsNothing()) { | 2074 | 2068 | return Nothing<bool>(); | @@ -2094,7 +2088,7 @@ BaseObjectPtr<BaseObject> NativeCryptoKey::CryptoKeyTransferData::Deserialize( | 2094 | 2088 | // Make sure internal/crypto/keys has been loaded so that the | 2095 | 2089 | // CryptoKey constructor is registered with the Environment. | 2096 | 2090 | Isolate* isolate = env->isolate(); | 2097 | | - Local<Value> arg = FIXED_ONE_BYTE_STRING(isolate, "internal/crypto/keys"); | | 2091 | + Local<Value> arg = env->internal_crypto_keys_string(); | 2098 | 2092 | if (env->builtin_module_require() | 2099 | 2093 | ->Call(context, Null(isolate), 1, &arg) | 2100 | 2094 | .IsEmpty()) { | |
Collapse file Copy file name to clipboardExpand all lines: src/crypto/crypto_util.cc +3-7Lines changed: 3 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -267,7 +267,7 @@ MaybeLocal<Value> cryptoErrorListToException(Environment* env, | 267 | 267 | // If there are no errors, it is likely a bug but we will return | 268 | 268 | // an error anyway. | 269 | 269 | if (errors.empty()) { | 270 | | - return Exception::Error(FIXED_ONE_BYTE_STRING(env->isolate(), "Ok")); | | 270 | + return Exception::Error(env->ok_string()); | 271 | 271 | } | 272 | 272 |
| 273 | 273 | // The last error in the list is the one that will be used as the | @@ -778,13 +778,9 @@ MaybeLocal<Value> CreateWebCryptoJobError(Environment* env, | 778 | 778 | CHECK(domexception_ctor->IsFunction()); | 779 | 779 |
| 780 | 780 | Local<Object> options = Object::New(isolate); | 781 | | - if (options | 782 | | - ->Set(context, | 783 | | - FIXED_ONE_BYTE_STRING(isolate, "name"), | 784 | | - FIXED_ONE_BYTE_STRING(isolate, "OperationError")) | | 781 | + if (options->Set(context, env->name_string(), env->operationerror_string()) | 785 | 782 | .IsNothing() || | 786 | | - options->Set(context, FIXED_ONE_BYTE_STRING(isolate, "cause"), cause) | 787 | | - .IsNothing()) { | | 783 | + options->Set(context, env->cause_string(), cause).IsNothing()) { | 788 | 784 | return {}; | 789 | 785 | } | 790 | 786 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/crypto/crypto_util.h +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -477,7 +477,7 @@ class CryptoJob : public AsyncWrap, public ThreadPoolWork { | 477 | 477 | { | 478 | 478 | node::errors::TryCatchScope try_catch(env); | 479 | 479 | if (value->IsObject()) { | 480 | | - then_key = FIXED_ONE_BYTE_STRING(env->isolate(), "then"); | | 480 | + then_key = env->then_string(); | 481 | 481 | v8::Local<v8::Object> object = value.As<v8::Object>(); | 482 | 482 | v8::Maybe<bool> has_own_then = | 483 | 483 | object->HasOwnProperty(context, then_key); | |
Collapse file Copy file name to clipboardExpand all lines: src/env_properties.h +16-1Lines changed: 16 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 82 | 82 | V(__dirname_string, "__dirname") \ | 83 | 83 | V(ack_string, "ack") \ | 84 | 84 | V(address_string, "address") \ | | 85 | + V(algorithm_string, "algorithm") \ | 85 | 86 | V(aliases_string, "aliases") \ | 86 | 87 | V(allow_bare_named_params_string, "allowBareNamedParameters") \ | 87 | 88 | V(allow_unknown_named_params_string, "allowUnknownNamedParameters") \ | | 93 | 94 | V(backup_string, "backup") \ | 94 | 95 | V(base_string, "base") \ | 95 | 96 | V(base_url_string, "baseURL") \ | | 97 | + V(brotli_string, "brotli") \ | 96 | 98 | V(buffer_string, "buffer") \ | 97 | 99 | V(bytes_parsed_string, "bytesParsed") \ | 98 | 100 | V(bytes_read_string, "bytesRead") \ | 99 | 101 | V(bytes_written_string, "bytesWritten") \ | 100 | 102 | V(cached_data_produced_string, "cachedDataProduced") \ | 101 | 103 | V(cached_data_rejected_string, "cachedDataRejected") \ | 102 | 104 | V(cached_data_string, "cachedData") \ | | 105 | + V(cause_string, "cause") \ | 103 | 106 | V(change_string, "change") \ | 104 | 107 | V(changes_string, "changes") \ | 105 | 108 | V(chunks_sent_since_last_write_string, "chunksSentSinceLastWrite") \ | | 180 | 183 | V(exponent_string, "exponent") \ | 181 | 184 | V(exports_string, "exports") \ | 182 | 185 | V(external_stream_string, "_externalStream") \ | | 186 | + V(extractable_string, "extractable") \ | 183 | 187 | V(family_string, "family") \ | 184 | 188 | V(fatal_exception_string, "_fatalException") \ | 185 | 189 | V(fd_string, "fd") \ | | 215 | 219 | V(ignore_string, "ignore") \ | 216 | 220 | V(inherit_string, "inherit") \ | 217 | 221 | V(input_string, "input") \ | | 222 | + V(internal_crypto_keys_string, "internal/crypto/keys") \ | 218 | 223 | V(inverse_string, "inverse") \ | 219 | 224 | V(ipv4_string, "IPv4") \ | 220 | 225 | V(ipv6_string, "IPv6") \ | | 264 | 269 | V(node_string, "node") \ | 265 | 270 | V(object_string, "Object") \ | 266 | 271 | V(ocsp_request_string, "OCSPRequest") \ | | 272 | + V(ok_string, "ok") \ | 267 | 273 | V(oncertcb_string, "oncertcb") \ | 268 | 274 | V(onchange_string, "onchange") \ | 269 | 275 | V(onclienthello_string, "onclienthello") \ | | 287 | 293 | V(onwrite_string, "onwrite") \ | 288 | 294 | V(ongracefulclosecomplete_string, "ongracefulclosecomplete") \ | 289 | 295 | V(openssl_error_stack, "opensslErrorStack") \ | | 296 | + V(operationerror_string, "OperationError") \ | 290 | 297 | V(options_string, "options") \ | 291 | 298 | V(original_string, "original") \ | 292 | 299 | V(output_string, "output") \ | 293 | 300 | V(overlapped_string, "overlapped") \ | | 301 | + V(p256_string, "P-256") \ | | 302 | + V(p384_string, "P-384") \ | | 303 | + V(p521_string, "P-521") \ | 294 | 304 | V(parse_error_string, "Parse Error") \ | 295 | 305 | V(password_string, "password") \ | 296 | 306 | V(path_string, "path") \ | | 333 | 343 | V(return_arrays_string, "returnArrays") \ | 334 | 344 | V(return_string, "return") \ | 335 | 345 | V(salt_length_string, "saltLength") \ | | 346 | + V(secp256k1_string, "secp256k1") \ | 336 | 347 | V(search_string, "search") \ | 337 | 348 | V(servername_string, "servername") \ | 338 | 349 | V(session_id_string, "sessionId") \ | | 361 | 372 | V(syscall_string, "syscall") \ | 362 | 373 | V(table_string, "table") \ | 363 | 374 | V(target_string, "target") \ | | 375 | + V(then_string, "then") \ | 364 | 376 | V(thread_id_string, "threadId") \ | 365 | 377 | V(thread_name_string, "threadName") \ | 366 | 378 | V(tls_group_string, "TLSGroup") \ | | 379 | 391 | V(uid_string, "uid") \ | 380 | 392 | V(unknown_string, "<unknown>") \ | 381 | 393 | V(url_string, "url") \ | | 394 | + V(usages_string, "usages") \ | 382 | 395 | V(username_string, "username") \ | 383 | 396 | V(value_string, "value") \ | 384 | 397 | V(verify_error_string, "verifyError") \ | | 388 | 401 | V(wrap_string, "wrap") \ | 389 | 402 | V(writable_string, "writable") \ | 390 | 403 | V(write_host_object_string, "_writeHostObject") \ | 391 | | - V(write_queue_size_string, "writeQueueSize") | | 404 | + V(write_queue_size_string, "writeQueueSize") \ | | 405 | + V(zlib_string, "zlib") \ | | 406 | + V(zstd_string, "zstd") | 392 | 407 |
| 393 | 408 | #define PER_ISOLATE_TEMPLATE_PROPERTIES(V) \ | 394 | 409 | V(a_record_template, v8::DictionaryTemplate) \ | |
Collapse file Copy file name to clipboardExpand all lines: src/node_ffi.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1210,7 +1210,7 @@ Local<FunctionTemplate> DynamicLibrary::GetConstructorTemplate( | 1210 | 1210 | DynamicLibrary::kInternalFieldCount); | 1211 | 1211 |
| 1212 | 1212 | tmpl->InstanceTemplate()->SetAccessorProperty( | 1213 | | - FIXED_ONE_BYTE_STRING(isolate, "path"), | | 1213 | + env->path_string(), | 1214 | 1214 | FunctionTemplate::New(env->isolate(), DynamicLibrary::GetPath), | 1215 | 1215 | Local<FunctionTemplate>(), | 1216 | 1216 | attributes); | |
Collapse file Copy file name to clipboardExpand all lines: src/permission/permission.cc +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -265,11 +265,11 @@ bool Permission::is_scope_granted(Environment* env, | 265 | 265 | v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0); | 266 | 266 | const char* perm_str = PermissionToString(permission); | 267 | 267 | msg->Set(context, | 268 | | - FIXED_ONE_BYTE_STRING(isolate, "permission"), | | 268 | + env->permission_string(), | 269 | 269 | v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked()) | 270 | 270 | .Check(); | 271 | 271 | msg->Set(context, | 272 | | - FIXED_ONE_BYTE_STRING(isolate, "resource"), | | 272 | + env->resource_string(), | 273 | 273 | v8::String::NewFromUtf8(isolate, | 274 | 274 | res.data(), | 275 | 275 | v8::NewStringType::kNormal, | @@ -335,11 +335,11 @@ void Permission::Drop(Environment* env, | 335 | 335 | v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0); | 336 | 336 | const char* perm_str = PermissionToString(scope); | 337 | 337 | msg->Set(context, | 338 | | - FIXED_ONE_BYTE_STRING(isolate, "permission"), | | 338 | + env->permission_string(), | 339 | 339 | v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked()) | 340 | 340 | .Check(); | 341 | 341 | msg->Set(context, | 342 | | - FIXED_ONE_BYTE_STRING(isolate, "resource"), | | 342 | + env->resource_string(), | 343 | 343 | v8::String::NewFromUtf8(isolate, | 344 | 344 | param.data(), | 345 | 345 | v8::NewStringType::kNormal, | |
|