Commit a293dbf

Browse files
jasnelladuh95
authored andcommitted
src: update repeated use strings to env
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #64760 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 3b8a0ba commit a293dbf

8 files changed

Lines changed: 42 additions & 40 deletions

File tree

‎src/crypto/crypto_context.cc‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,12 +2255,9 @@ void SecureContext::GetCertificateCompressionAlgorithms(
22552255
Environment* env = Environment::GetCurrent(args);
22562256
LocalVector<Value> algs(env->isolate());
22572257
#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());
22642261
#endif
22652262
args.GetReturnValue().Set(
22662263
Array::New(env->isolate(), algs.data(), algs.size()));

‎src/crypto/crypto_ec.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,16 +520,16 @@ bool ExportJWKEcKey(Environment* env,
520520
constint nid = EC_GROUP_get_curve_name(group);
521521
switch (nid) {
522522
case NID_X9_62_prime256v1:
523-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-256");
523+
crv_name = env->p256_string();
524524
break;
525525
case NID_secp256k1:
526-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "secp256k1");
526+
crv_name = env->secp256k1_string();
527527
break;
528528
case NID_secp384r1:
529-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-384");
529+
crv_name = env->p384_string();
530530
break;
531531
case NID_secp521r1:
532-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-521");
532+
crv_name = env->p521_string();
533533
break;
534534
default: {
535535
THROW_ERR_CRYPTO_JWK_UNSUPPORTED_CURVE(

‎src/crypto/crypto_keys.cc‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,8 +1796,7 @@ BaseObjectPtr<BaseObject> NativeKeyObject::KeyObjectTransferData::Deserialize(
17961796
return {};
17971797

17981798
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();
18011800
if (env->builtin_module_require()
18021801
->Call(context, Null(env->isolate()), 1, &arg)
18031802
.IsEmpty()) {
@@ -1875,7 +1874,7 @@ MaybeLocal<Value> NativeCryptoKey::Create(Environment* env,
18751874
if (!KeyObjectHandle::Create(env, data).ToLocal(&handle)) return {};
18761875

18771876
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();
18791878
if (env->builtin_module_require()
18801879
->Call(context, Null(isolate), 1, &arg)
18811880
.IsEmpty()) {
@@ -2017,31 +2016,28 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20172016
}
20182017
CHECK(bundle_v->IsObject());
20192018
Local<Object> bundle = bundle_v.As<Object>();
2020-
Isolate* isolate = env()->isolate();
20212019
Local<Object> obj = object();
20222020

20232021
// The partially-initialized object produced by
20242022
// CryptoKeyTransferData::Deserialize should not have algorithm set yet.
20252023
CHECK(obj->GetInternalField(kAlgorithmField).As<Value>()->IsUndefined());
20262024

20272025
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)) {
20302027
return Nothing<void>();
20312028
}
20322029
CHECK(algorithm_v->IsObject());
20332030
obj->SetInternalField(kAlgorithmField, algorithm_v);
20342031

20352032
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)) {
20382034
return Nothing<void>();
20392035
}
20402036
CHECK(usages_v->IsUint32());
20412037
usages_mask_ = usages_v.As<Uint32>()->Value();
20422038

20432039
Local<Value> extractable_v;
2044-
if (!bundle->Get(context, FIXED_ONE_BYTE_STRING(isolate, "extractable"))
2040+
if (!bundle->Get(context, env()->extractable_string())
20452041
.ToLocal(&extractable_v)) {
20462042
return Nothing<void>();
20472043
}
@@ -2054,21 +2050,19 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20542050
Maybe<bool> NativeCryptoKey::CryptoKeyTransferData::FinalizeTransferWrite(
20552051
Local<Context> context, v8::ValueSerializer* serializer) {
20562052
Isolate* isolate = Isolate::GetCurrent();
2053+
Environment* env = Environment::GetCurrent(isolate);
20572054
CHECK(!algorithm_.IsEmpty());
20582055
Local<Object> bundle = Object::New(isolate);
20592056
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() ||
20642058
bundle
20652059
->Set(context,
2066-
FIXED_ONE_BYTE_STRING(isolate, "usages"),
2060+
env->usages_string(),
20672061
Uint32::NewFromUnsigned(isolate, usages_mask_))
20682062
.IsNothing() ||
20692063
bundle
20702064
->Set(context,
2071-
FIXED_ONE_BYTE_STRING(isolate, "extractable"),
2065+
env->extractable_string(),
20722066
v8::Boolean::New(isolate, extractable_))
20732067
.IsNothing()) {
20742068
return Nothing<bool>();
@@ -2094,7 +2088,7 @@ BaseObjectPtr<BaseObject> NativeCryptoKey::CryptoKeyTransferData::Deserialize(
20942088
// Make sure internal/crypto/keys has been loaded so that the
20952089
// CryptoKey constructor is registered with the Environment.
20962090
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();
20982092
if (env->builtin_module_require()
20992093
->Call(context, Null(isolate), 1, &arg)
21002094
.IsEmpty()) {

‎src/crypto/crypto_util.cc‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ MaybeLocal<Value> cryptoErrorListToException(Environment* env,
267267
// If there are no errors, it is likely a bug but we will return
268268
// an error anyway.
269269
if (errors.empty()) {
270-
returnException::Error(FIXED_ONE_BYTE_STRING(env->isolate(), "Ok"));
270+
returnException::Error(env->ok_string());
271271
}
272272

273273
// The last error in the list is the one that will be used as the
@@ -778,13 +778,9 @@ MaybeLocal<Value> CreateWebCryptoJobError(Environment* env,
778778
CHECK(domexception_ctor->IsFunction());
779779

780780
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())
785782
.IsNothing() ||
786-
options->Set(context, FIXED_ONE_BYTE_STRING(isolate, "cause"), cause)
787-
.IsNothing()) {
783+
options->Set(context, env->cause_string(), cause).IsNothing()) {
788784
return {};
789785
}
790786

‎src/crypto/crypto_util.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ class CryptoJob : public AsyncWrap, public ThreadPoolWork {
477477
{
478478
node::errors::TryCatchScope try_catch(env);
479479
if (value->IsObject()) {
480-
then_key = FIXED_ONE_BYTE_STRING(env->isolate(), "then");
480+
then_key = env->then_string();
481481
v8::Local<v8::Object> object = value.As<v8::Object>();
482482
v8::Maybe<bool> has_own_then =
483483
object->HasOwnProperty(context, then_key);

‎src/env_properties.h‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
V(__dirname_string, "__dirname") \
8383
V(ack_string, "ack") \
8484
V(address_string, "address") \
85+
V(algorithm_string, "algorithm") \
8586
V(aliases_string, "aliases") \
8687
V(allow_bare_named_params_string, "allowBareNamedParameters") \
8788
V(allow_unknown_named_params_string, "allowUnknownNamedParameters") \
@@ -93,13 +94,15 @@
9394
V(backup_string, "backup") \
9495
V(base_string, "base") \
9596
V(base_url_string, "baseURL") \
97+
V(brotli_string, "brotli") \
9698
V(buffer_string, "buffer") \
9799
V(bytes_parsed_string, "bytesParsed") \
98100
V(bytes_read_string, "bytesRead") \
99101
V(bytes_written_string, "bytesWritten") \
100102
V(cached_data_produced_string, "cachedDataProduced") \
101103
V(cached_data_rejected_string, "cachedDataRejected") \
102104
V(cached_data_string, "cachedData") \
105+
V(cause_string, "cause") \
103106
V(change_string, "change") \
104107
V(changes_string, "changes") \
105108
V(chunks_sent_since_last_write_string, "chunksSentSinceLastWrite") \
@@ -180,6 +183,7 @@
180183
V(exponent_string, "exponent") \
181184
V(exports_string, "exports") \
182185
V(external_stream_string, "_externalStream") \
186+
V(extractable_string, "extractable") \
183187
V(family_string, "family") \
184188
V(fatal_exception_string, "_fatalException") \
185189
V(fd_string, "fd") \
@@ -215,6 +219,7 @@
215219
V(ignore_string, "ignore") \
216220
V(inherit_string, "inherit") \
217221
V(input_string, "input") \
222+
V(internal_crypto_keys_string, "internal/crypto/keys") \
218223
V(inverse_string, "inverse") \
219224
V(ipv4_string, "IPv4") \
220225
V(ipv6_string, "IPv6") \
@@ -264,6 +269,7 @@
264269
V(node_string, "node") \
265270
V(object_string, "Object") \
266271
V(ocsp_request_string, "OCSPRequest") \
272+
V(ok_string, "ok") \
267273
V(oncertcb_string, "oncertcb") \
268274
V(onchange_string, "onchange") \
269275
V(onclienthello_string, "onclienthello") \
@@ -287,10 +293,14 @@
287293
V(onwrite_string, "onwrite") \
288294
V(ongracefulclosecomplete_string, "ongracefulclosecomplete") \
289295
V(openssl_error_stack, "opensslErrorStack") \
296+
V(operationerror_string, "OperationError") \
290297
V(options_string, "options") \
291298
V(original_string, "original") \
292299
V(output_string, "output") \
293300
V(overlapped_string, "overlapped") \
301+
V(p256_string, "P-256") \
302+
V(p384_string, "P-384") \
303+
V(p521_string, "P-521") \
294304
V(parse_error_string, "Parse Error") \
295305
V(password_string, "password") \
296306
V(path_string, "path") \
@@ -333,6 +343,7 @@
333343
V(return_arrays_string, "returnArrays") \
334344
V(return_string, "return") \
335345
V(salt_length_string, "saltLength") \
346+
V(secp256k1_string, "secp256k1") \
336347
V(search_string, "search") \
337348
V(servername_string, "servername") \
338349
V(session_id_string, "sessionId") \
@@ -361,6 +372,7 @@
361372
V(syscall_string, "syscall") \
362373
V(table_string, "table") \
363374
V(target_string, "target") \
375+
V(then_string, "then") \
364376
V(thread_id_string, "threadId") \
365377
V(thread_name_string, "threadName") \
366378
V(tls_group_string, "TLSGroup") \
@@ -379,6 +391,7 @@
379391
V(uid_string, "uid") \
380392
V(unknown_string, "<unknown>") \
381393
V(url_string, "url") \
394+
V(usages_string, "usages") \
382395
V(username_string, "username") \
383396
V(value_string, "value") \
384397
V(verify_error_string, "verifyError") \
@@ -388,7 +401,9 @@
388401
V(wrap_string, "wrap") \
389402
V(writable_string, "writable") \
390403
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")
392407

393408
#definePER_ISOLATE_TEMPLATE_PROPERTIES(V) \
394409
V(a_record_template, v8::DictionaryTemplate) \

‎src/node_ffi.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ Local<FunctionTemplate> DynamicLibrary::GetConstructorTemplate(
12101210
DynamicLibrary::kInternalFieldCount);
12111211

12121212
tmpl->InstanceTemplate()->SetAccessorProperty(
1213-
FIXED_ONE_BYTE_STRING(isolate, "path"),
1213+
env->path_string(),
12141214
FunctionTemplate::New(env->isolate(), DynamicLibrary::GetPath),
12151215
Local<FunctionTemplate>(),
12161216
attributes);

‎src/permission/permission.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ bool Permission::is_scope_granted(Environment* env,
265265
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
266266
constchar* perm_str = PermissionToString(permission);
267267
msg->Set(context,
268-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
268+
env->permission_string(),
269269
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
270270
.Check();
271271
msg->Set(context,
272-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
272+
env->resource_string(),
273273
v8::String::NewFromUtf8(isolate,
274274
res.data(),
275275
v8::NewStringType::kNormal,
@@ -335,11 +335,11 @@ void Permission::Drop(Environment* env,
335335
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
336336
constchar* perm_str = PermissionToString(scope);
337337
msg->Set(context,
338-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
338+
env->permission_string(),
339339
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
340340
.Check();
341341
msg->Set(context,
342-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
342+
env->resource_string(),
343343
v8::String::NewFromUtf8(isolate,
344344
param.data(),
345345
v8::NewStringType::kNormal,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Commit a293dbf

Browse files
jasnelladuh95
authored andcommitted
src: update repeated use strings to env
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #64760 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 3b8a0ba commit a293dbf

8 files changed

Lines changed: 42 additions & 40 deletions

File tree

‎src/crypto/crypto_context.cc‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,12 +2255,9 @@ void SecureContext::GetCertificateCompressionAlgorithms(
22552255
Environment* env = Environment::GetCurrent(args);
22562256
LocalVector<Value> algs(env->isolate());
22572257
#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());
22642261
#endif
22652262
args.GetReturnValue().Set(
22662263
Array::New(env->isolate(), algs.data(), algs.size()));

‎src/crypto/crypto_ec.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,16 +520,16 @@ bool ExportJWKEcKey(Environment* env,
520520
constint nid = EC_GROUP_get_curve_name(group);
521521
switch (nid) {
522522
case NID_X9_62_prime256v1:
523-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-256");
523+
crv_name = env->p256_string();
524524
break;
525525
case NID_secp256k1:
526-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "secp256k1");
526+
crv_name = env->secp256k1_string();
527527
break;
528528
case NID_secp384r1:
529-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-384");
529+
crv_name = env->p384_string();
530530
break;
531531
case NID_secp521r1:
532-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-521");
532+
crv_name = env->p521_string();
533533
break;
534534
default: {
535535
THROW_ERR_CRYPTO_JWK_UNSUPPORTED_CURVE(

‎src/crypto/crypto_keys.cc‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,8 +1796,7 @@ BaseObjectPtr<BaseObject> NativeKeyObject::KeyObjectTransferData::Deserialize(
17961796
return {};
17971797

17981798
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();
18011800
if (env->builtin_module_require()
18021801
->Call(context, Null(env->isolate()), 1, &arg)
18031802
.IsEmpty()) {
@@ -1875,7 +1874,7 @@ MaybeLocal<Value> NativeCryptoKey::Create(Environment* env,
18751874
if (!KeyObjectHandle::Create(env, data).ToLocal(&handle)) return {};
18761875

18771876
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();
18791878
if (env->builtin_module_require()
18801879
->Call(context, Null(isolate), 1, &arg)
18811880
.IsEmpty()) {
@@ -2017,31 +2016,28 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20172016
}
20182017
CHECK(bundle_v->IsObject());
20192018
Local<Object> bundle = bundle_v.As<Object>();
2020-
Isolate* isolate = env()->isolate();
20212019
Local<Object> obj = object();
20222020

20232021
// The partially-initialized object produced by
20242022
// CryptoKeyTransferData::Deserialize should not have algorithm set yet.
20252023
CHECK(obj->GetInternalField(kAlgorithmField).As<Value>()->IsUndefined());
20262024

20272025
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)) {
20302027
return Nothing<void>();
20312028
}
20322029
CHECK(algorithm_v->IsObject());
20332030
obj->SetInternalField(kAlgorithmField, algorithm_v);
20342031

20352032
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)) {
20382034
return Nothing<void>();
20392035
}
20402036
CHECK(usages_v->IsUint32());
20412037
usages_mask_ = usages_v.As<Uint32>()->Value();
20422038

20432039
Local<Value> extractable_v;
2044-
if (!bundle->Get(context, FIXED_ONE_BYTE_STRING(isolate, "extractable"))
2040+
if (!bundle->Get(context, env()->extractable_string())
20452041
.ToLocal(&extractable_v)) {
20462042
return Nothing<void>();
20472043
}
@@ -2054,21 +2050,19 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20542050
Maybe<bool> NativeCryptoKey::CryptoKeyTransferData::FinalizeTransferWrite(
20552051
Local<Context> context, v8::ValueSerializer* serializer) {
20562052
Isolate* isolate = Isolate::GetCurrent();
2053+
Environment* env = Environment::GetCurrent(isolate);
20572054
CHECK(!algorithm_.IsEmpty());
20582055
Local<Object> bundle = Object::New(isolate);
20592056
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() ||
20642058
bundle
20652059
->Set(context,
2066-
FIXED_ONE_BYTE_STRING(isolate, "usages"),
2060+
env->usages_string(),
20672061
Uint32::NewFromUnsigned(isolate, usages_mask_))
20682062
.IsNothing() ||
20692063
bundle
20702064
->Set(context,
2071-
FIXED_ONE_BYTE_STRING(isolate, "extractable"),
2065+
env->extractable_string(),
20722066
v8::Boolean::New(isolate, extractable_))
20732067
.IsNothing()) {
20742068
return Nothing<bool>();
@@ -2094,7 +2088,7 @@ BaseObjectPtr<BaseObject> NativeCryptoKey::CryptoKeyTransferData::Deserialize(
20942088
// Make sure internal/crypto/keys has been loaded so that the
20952089
// CryptoKey constructor is registered with the Environment.
20962090
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();
20982092
if (env->builtin_module_require()
20992093
->Call(context, Null(isolate), 1, &arg)
21002094
.IsEmpty()) {

‎src/crypto/crypto_util.cc‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ MaybeLocal<Value> cryptoErrorListToException(Environment* env,
267267
// If there are no errors, it is likely a bug but we will return
268268
// an error anyway.
269269
if (errors.empty()) {
270-
returnException::Error(FIXED_ONE_BYTE_STRING(env->isolate(), "Ok"));
270+
returnException::Error(env->ok_string());
271271
}
272272

273273
// The last error in the list is the one that will be used as the
@@ -778,13 +778,9 @@ MaybeLocal<Value> CreateWebCryptoJobError(Environment* env,
778778
CHECK(domexception_ctor->IsFunction());
779779

780780
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())
785782
.IsNothing() ||
786-
options->Set(context, FIXED_ONE_BYTE_STRING(isolate, "cause"), cause)
787-
.IsNothing()) {
783+
options->Set(context, env->cause_string(), cause).IsNothing()) {
788784
return {};
789785
}
790786

‎src/crypto/crypto_util.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ class CryptoJob : public AsyncWrap, public ThreadPoolWork {
477477
{
478478
node::errors::TryCatchScope try_catch(env);
479479
if (value->IsObject()) {
480-
then_key = FIXED_ONE_BYTE_STRING(env->isolate(), "then");
480+
then_key = env->then_string();
481481
v8::Local<v8::Object> object = value.As<v8::Object>();
482482
v8::Maybe<bool> has_own_then =
483483
object->HasOwnProperty(context, then_key);

‎src/env_properties.h‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
V(__dirname_string, "__dirname") \
8383
V(ack_string, "ack") \
8484
V(address_string, "address") \
85+
V(algorithm_string, "algorithm") \
8586
V(aliases_string, "aliases") \
8687
V(allow_bare_named_params_string, "allowBareNamedParameters") \
8788
V(allow_unknown_named_params_string, "allowUnknownNamedParameters") \
@@ -93,13 +94,15 @@
9394
V(backup_string, "backup") \
9495
V(base_string, "base") \
9596
V(base_url_string, "baseURL") \
97+
V(brotli_string, "brotli") \
9698
V(buffer_string, "buffer") \
9799
V(bytes_parsed_string, "bytesParsed") \
98100
V(bytes_read_string, "bytesRead") \
99101
V(bytes_written_string, "bytesWritten") \
100102
V(cached_data_produced_string, "cachedDataProduced") \
101103
V(cached_data_rejected_string, "cachedDataRejected") \
102104
V(cached_data_string, "cachedData") \
105+
V(cause_string, "cause") \
103106
V(change_string, "change") \
104107
V(changes_string, "changes") \
105108
V(chunks_sent_since_last_write_string, "chunksSentSinceLastWrite") \
@@ -180,6 +183,7 @@
180183
V(exponent_string, "exponent") \
181184
V(exports_string, "exports") \
182185
V(external_stream_string, "_externalStream") \
186+
V(extractable_string, "extractable") \
183187
V(family_string, "family") \
184188
V(fatal_exception_string, "_fatalException") \
185189
V(fd_string, "fd") \
@@ -215,6 +219,7 @@
215219
V(ignore_string, "ignore") \
216220
V(inherit_string, "inherit") \
217221
V(input_string, "input") \
222+
V(internal_crypto_keys_string, "internal/crypto/keys") \
218223
V(inverse_string, "inverse") \
219224
V(ipv4_string, "IPv4") \
220225
V(ipv6_string, "IPv6") \
@@ -264,6 +269,7 @@
264269
V(node_string, "node") \
265270
V(object_string, "Object") \
266271
V(ocsp_request_string, "OCSPRequest") \
272+
V(ok_string, "ok") \
267273
V(oncertcb_string, "oncertcb") \
268274
V(onchange_string, "onchange") \
269275
V(onclienthello_string, "onclienthello") \
@@ -287,10 +293,14 @@
287293
V(onwrite_string, "onwrite") \
288294
V(ongracefulclosecomplete_string, "ongracefulclosecomplete") \
289295
V(openssl_error_stack, "opensslErrorStack") \
296+
V(operationerror_string, "OperationError") \
290297
V(options_string, "options") \
291298
V(original_string, "original") \
292299
V(output_string, "output") \
293300
V(overlapped_string, "overlapped") \
301+
V(p256_string, "P-256") \
302+
V(p384_string, "P-384") \
303+
V(p521_string, "P-521") \
294304
V(parse_error_string, "Parse Error") \
295305
V(password_string, "password") \
296306
V(path_string, "path") \
@@ -333,6 +343,7 @@
333343
V(return_arrays_string, "returnArrays") \
334344
V(return_string, "return") \
335345
V(salt_length_string, "saltLength") \
346+
V(secp256k1_string, "secp256k1") \
336347
V(search_string, "search") \
337348
V(servername_string, "servername") \
338349
V(session_id_string, "sessionId") \
@@ -361,6 +372,7 @@
361372
V(syscall_string, "syscall") \
362373
V(table_string, "table") \
363374
V(target_string, "target") \
375+
V(then_string, "then") \
364376
V(thread_id_string, "threadId") \
365377
V(thread_name_string, "threadName") \
366378
V(tls_group_string, "TLSGroup") \
@@ -379,6 +391,7 @@
379391
V(uid_string, "uid") \
380392
V(unknown_string, "<unknown>") \
381393
V(url_string, "url") \
394+
V(usages_string, "usages") \
382395
V(username_string, "username") \
383396
V(value_string, "value") \
384397
V(verify_error_string, "verifyError") \
@@ -388,7 +401,9 @@
388401
V(wrap_string, "wrap") \
389402
V(writable_string, "writable") \
390403
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")
392407

393408
#definePER_ISOLATE_TEMPLATE_PROPERTIES(V) \
394409
V(a_record_template, v8::DictionaryTemplate) \

‎src/node_ffi.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ Local<FunctionTemplate> DynamicLibrary::GetConstructorTemplate(
12101210
DynamicLibrary::kInternalFieldCount);
12111211

12121212
tmpl->InstanceTemplate()->SetAccessorProperty(
1213-
FIXED_ONE_BYTE_STRING(isolate, "path"),
1213+
env->path_string(),
12141214
FunctionTemplate::New(env->isolate(), DynamicLibrary::GetPath),
12151215
Local<FunctionTemplate>(),
12161216
attributes);

‎src/permission/permission.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ bool Permission::is_scope_granted(Environment* env,
265265
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
266266
constchar* perm_str = PermissionToString(permission);
267267
msg->Set(context,
268-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
268+
env->permission_string(),
269269
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
270270
.Check();
271271
msg->Set(context,
272-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
272+
env->resource_string(),
273273
v8::String::NewFromUtf8(isolate,
274274
res.data(),
275275
v8::NewStringType::kNormal,
@@ -335,11 +335,11 @@ void Permission::Drop(Environment* env,
335335
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
336336
constchar* perm_str = PermissionToString(scope);
337337
msg->Set(context,
338-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
338+
env->permission_string(),
339339
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
340340
.Check();
341341
msg->Set(context,
342-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
342+
env->resource_string(),
343343
v8::String::NewFromUtf8(isolate,
344344
param.data(),
345345
v8::NewStringType::kNormal,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit a293dbf

Browse files
jasnelladuh95
authored andcommitted
src: update repeated use strings to env
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #64760 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 3b8a0ba commit a293dbf

8 files changed

Lines changed: 42 additions & 40 deletions

File tree

‎src/crypto/crypto_context.cc‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,12 +2255,9 @@ void SecureContext::GetCertificateCompressionAlgorithms(
22552255
Environment* env = Environment::GetCurrent(args);
22562256
LocalVector<Value> algs(env->isolate());
22572257
#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());
22642261
#endif
22652262
args.GetReturnValue().Set(
22662263
Array::New(env->isolate(), algs.data(), algs.size()));

‎src/crypto/crypto_ec.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,16 +520,16 @@ bool ExportJWKEcKey(Environment* env,
520520
constint nid = EC_GROUP_get_curve_name(group);
521521
switch (nid) {
522522
case NID_X9_62_prime256v1:
523-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-256");
523+
crv_name = env->p256_string();
524524
break;
525525
case NID_secp256k1:
526-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "secp256k1");
526+
crv_name = env->secp256k1_string();
527527
break;
528528
case NID_secp384r1:
529-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-384");
529+
crv_name = env->p384_string();
530530
break;
531531
case NID_secp521r1:
532-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-521");
532+
crv_name = env->p521_string();
533533
break;
534534
default: {
535535
THROW_ERR_CRYPTO_JWK_UNSUPPORTED_CURVE(

‎src/crypto/crypto_keys.cc‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,8 +1796,7 @@ BaseObjectPtr<BaseObject> NativeKeyObject::KeyObjectTransferData::Deserialize(
17961796
return {};
17971797

17981798
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();
18011800
if (env->builtin_module_require()
18021801
->Call(context, Null(env->isolate()), 1, &arg)
18031802
.IsEmpty()) {
@@ -1875,7 +1874,7 @@ MaybeLocal<Value> NativeCryptoKey::Create(Environment* env,
18751874
if (!KeyObjectHandle::Create(env, data).ToLocal(&handle)) return {};
18761875

18771876
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();
18791878
if (env->builtin_module_require()
18801879
->Call(context, Null(isolate), 1, &arg)
18811880
.IsEmpty()) {
@@ -2017,31 +2016,28 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20172016
}
20182017
CHECK(bundle_v->IsObject());
20192018
Local<Object> bundle = bundle_v.As<Object>();
2020-
Isolate* isolate = env()->isolate();
20212019
Local<Object> obj = object();
20222020

20232021
// The partially-initialized object produced by
20242022
// CryptoKeyTransferData::Deserialize should not have algorithm set yet.
20252023
CHECK(obj->GetInternalField(kAlgorithmField).As<Value>()->IsUndefined());
20262024

20272025
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)) {
20302027
return Nothing<void>();
20312028
}
20322029
CHECK(algorithm_v->IsObject());
20332030
obj->SetInternalField(kAlgorithmField, algorithm_v);
20342031

20352032
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)) {
20382034
return Nothing<void>();
20392035
}
20402036
CHECK(usages_v->IsUint32());
20412037
usages_mask_ = usages_v.As<Uint32>()->Value();
20422038

20432039
Local<Value> extractable_v;
2044-
if (!bundle->Get(context, FIXED_ONE_BYTE_STRING(isolate, "extractable"))
2040+
if (!bundle->Get(context, env()->extractable_string())
20452041
.ToLocal(&extractable_v)) {
20462042
return Nothing<void>();
20472043
}
@@ -2054,21 +2050,19 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20542050
Maybe<bool> NativeCryptoKey::CryptoKeyTransferData::FinalizeTransferWrite(
20552051
Local<Context> context, v8::ValueSerializer* serializer) {
20562052
Isolate* isolate = Isolate::GetCurrent();
2053+
Environment* env = Environment::GetCurrent(isolate);
20572054
CHECK(!algorithm_.IsEmpty());
20582055
Local<Object> bundle = Object::New(isolate);
20592056
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() ||
20642058
bundle
20652059
->Set(context,
2066-
FIXED_ONE_BYTE_STRING(isolate, "usages"),
2060+
env->usages_string(),
20672061
Uint32::NewFromUnsigned(isolate, usages_mask_))
20682062
.IsNothing() ||
20692063
bundle
20702064
->Set(context,
2071-
FIXED_ONE_BYTE_STRING(isolate, "extractable"),
2065+
env->extractable_string(),
20722066
v8::Boolean::New(isolate, extractable_))
20732067
.IsNothing()) {
20742068
return Nothing<bool>();
@@ -2094,7 +2088,7 @@ BaseObjectPtr<BaseObject> NativeCryptoKey::CryptoKeyTransferData::Deserialize(
20942088
// Make sure internal/crypto/keys has been loaded so that the
20952089
// CryptoKey constructor is registered with the Environment.
20962090
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();
20982092
if (env->builtin_module_require()
20992093
->Call(context, Null(isolate), 1, &arg)
21002094
.IsEmpty()) {

‎src/crypto/crypto_util.cc‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ MaybeLocal<Value> cryptoErrorListToException(Environment* env,
267267
// If there are no errors, it is likely a bug but we will return
268268
// an error anyway.
269269
if (errors.empty()) {
270-
returnException::Error(FIXED_ONE_BYTE_STRING(env->isolate(), "Ok"));
270+
returnException::Error(env->ok_string());
271271
}
272272

273273
// The last error in the list is the one that will be used as the
@@ -778,13 +778,9 @@ MaybeLocal<Value> CreateWebCryptoJobError(Environment* env,
778778
CHECK(domexception_ctor->IsFunction());
779779

780780
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())
785782
.IsNothing() ||
786-
options->Set(context, FIXED_ONE_BYTE_STRING(isolate, "cause"), cause)
787-
.IsNothing()) {
783+
options->Set(context, env->cause_string(), cause).IsNothing()) {
788784
return {};
789785
}
790786

‎src/crypto/crypto_util.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ class CryptoJob : public AsyncWrap, public ThreadPoolWork {
477477
{
478478
node::errors::TryCatchScope try_catch(env);
479479
if (value->IsObject()) {
480-
then_key = FIXED_ONE_BYTE_STRING(env->isolate(), "then");
480+
then_key = env->then_string();
481481
v8::Local<v8::Object> object = value.As<v8::Object>();
482482
v8::Maybe<bool> has_own_then =
483483
object->HasOwnProperty(context, then_key);

‎src/env_properties.h‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
V(__dirname_string, "__dirname") \
8383
V(ack_string, "ack") \
8484
V(address_string, "address") \
85+
V(algorithm_string, "algorithm") \
8586
V(aliases_string, "aliases") \
8687
V(allow_bare_named_params_string, "allowBareNamedParameters") \
8788
V(allow_unknown_named_params_string, "allowUnknownNamedParameters") \
@@ -93,13 +94,15 @@
9394
V(backup_string, "backup") \
9495
V(base_string, "base") \
9596
V(base_url_string, "baseURL") \
97+
V(brotli_string, "brotli") \
9698
V(buffer_string, "buffer") \
9799
V(bytes_parsed_string, "bytesParsed") \
98100
V(bytes_read_string, "bytesRead") \
99101
V(bytes_written_string, "bytesWritten") \
100102
V(cached_data_produced_string, "cachedDataProduced") \
101103
V(cached_data_rejected_string, "cachedDataRejected") \
102104
V(cached_data_string, "cachedData") \
105+
V(cause_string, "cause") \
103106
V(change_string, "change") \
104107
V(changes_string, "changes") \
105108
V(chunks_sent_since_last_write_string, "chunksSentSinceLastWrite") \
@@ -180,6 +183,7 @@
180183
V(exponent_string, "exponent") \
181184
V(exports_string, "exports") \
182185
V(external_stream_string, "_externalStream") \
186+
V(extractable_string, "extractable") \
183187
V(family_string, "family") \
184188
V(fatal_exception_string, "_fatalException") \
185189
V(fd_string, "fd") \
@@ -215,6 +219,7 @@
215219
V(ignore_string, "ignore") \
216220
V(inherit_string, "inherit") \
217221
V(input_string, "input") \
222+
V(internal_crypto_keys_string, "internal/crypto/keys") \
218223
V(inverse_string, "inverse") \
219224
V(ipv4_string, "IPv4") \
220225
V(ipv6_string, "IPv6") \
@@ -264,6 +269,7 @@
264269
V(node_string, "node") \
265270
V(object_string, "Object") \
266271
V(ocsp_request_string, "OCSPRequest") \
272+
V(ok_string, "ok") \
267273
V(oncertcb_string, "oncertcb") \
268274
V(onchange_string, "onchange") \
269275
V(onclienthello_string, "onclienthello") \
@@ -287,10 +293,14 @@
287293
V(onwrite_string, "onwrite") \
288294
V(ongracefulclosecomplete_string, "ongracefulclosecomplete") \
289295
V(openssl_error_stack, "opensslErrorStack") \
296+
V(operationerror_string, "OperationError") \
290297
V(options_string, "options") \
291298
V(original_string, "original") \
292299
V(output_string, "output") \
293300
V(overlapped_string, "overlapped") \
301+
V(p256_string, "P-256") \
302+
V(p384_string, "P-384") \
303+
V(p521_string, "P-521") \
294304
V(parse_error_string, "Parse Error") \
295305
V(password_string, "password") \
296306
V(path_string, "path") \
@@ -333,6 +343,7 @@
333343
V(return_arrays_string, "returnArrays") \
334344
V(return_string, "return") \
335345
V(salt_length_string, "saltLength") \
346+
V(secp256k1_string, "secp256k1") \
336347
V(search_string, "search") \
337348
V(servername_string, "servername") \
338349
V(session_id_string, "sessionId") \
@@ -361,6 +372,7 @@
361372
V(syscall_string, "syscall") \
362373
V(table_string, "table") \
363374
V(target_string, "target") \
375+
V(then_string, "then") \
364376
V(thread_id_string, "threadId") \
365377
V(thread_name_string, "threadName") \
366378
V(tls_group_string, "TLSGroup") \
@@ -379,6 +391,7 @@
379391
V(uid_string, "uid") \
380392
V(unknown_string, "<unknown>") \
381393
V(url_string, "url") \
394+
V(usages_string, "usages") \
382395
V(username_string, "username") \
383396
V(value_string, "value") \
384397
V(verify_error_string, "verifyError") \
@@ -388,7 +401,9 @@
388401
V(wrap_string, "wrap") \
389402
V(writable_string, "writable") \
390403
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")
392407

393408
#definePER_ISOLATE_TEMPLATE_PROPERTIES(V) \
394409
V(a_record_template, v8::DictionaryTemplate) \

‎src/node_ffi.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ Local<FunctionTemplate> DynamicLibrary::GetConstructorTemplate(
12101210
DynamicLibrary::kInternalFieldCount);
12111211

12121212
tmpl->InstanceTemplate()->SetAccessorProperty(
1213-
FIXED_ONE_BYTE_STRING(isolate, "path"),
1213+
env->path_string(),
12141214
FunctionTemplate::New(env->isolate(), DynamicLibrary::GetPath),
12151215
Local<FunctionTemplate>(),
12161216
attributes);

‎src/permission/permission.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ bool Permission::is_scope_granted(Environment* env,
265265
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
266266
constchar* perm_str = PermissionToString(permission);
267267
msg->Set(context,
268-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
268+
env->permission_string(),
269269
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
270270
.Check();
271271
msg->Set(context,
272-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
272+
env->resource_string(),
273273
v8::String::NewFromUtf8(isolate,
274274
res.data(),
275275
v8::NewStringType::kNormal,
@@ -335,11 +335,11 @@ void Permission::Drop(Environment* env,
335335
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
336336
constchar* perm_str = PermissionToString(scope);
337337
msg->Set(context,
338-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
338+
env->permission_string(),
339339
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
340340
.Check();
341341
msg->Set(context,
342-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
342+
env->resource_string(),
343343
v8::String::NewFromUtf8(isolate,
344344
param.data(),
345345
v8::NewStringType::kNormal,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit a293dbf

Browse files
jasnelladuh95
authored andcommitted
src: update repeated use strings to env
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #64760 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 3b8a0ba commit a293dbf

8 files changed

Lines changed: 42 additions & 40 deletions

File tree

‎src/crypto/crypto_context.cc‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,12 +2255,9 @@ void SecureContext::GetCertificateCompressionAlgorithms(
22552255
Environment* env = Environment::GetCurrent(args);
22562256
LocalVector<Value> algs(env->isolate());
22572257
#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());
22642261
#endif
22652262
args.GetReturnValue().Set(
22662263
Array::New(env->isolate(), algs.data(), algs.size()));

‎src/crypto/crypto_ec.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,16 +520,16 @@ bool ExportJWKEcKey(Environment* env,
520520
constint nid = EC_GROUP_get_curve_name(group);
521521
switch (nid) {
522522
case NID_X9_62_prime256v1:
523-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-256");
523+
crv_name = env->p256_string();
524524
break;
525525
case NID_secp256k1:
526-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "secp256k1");
526+
crv_name = env->secp256k1_string();
527527
break;
528528
case NID_secp384r1:
529-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-384");
529+
crv_name = env->p384_string();
530530
break;
531531
case NID_secp521r1:
532-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-521");
532+
crv_name = env->p521_string();
533533
break;
534534
default: {
535535
THROW_ERR_CRYPTO_JWK_UNSUPPORTED_CURVE(

‎src/crypto/crypto_keys.cc‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,8 +1796,7 @@ BaseObjectPtr<BaseObject> NativeKeyObject::KeyObjectTransferData::Deserialize(
17961796
return {};
17971797

17981798
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();
18011800
if (env->builtin_module_require()
18021801
->Call(context, Null(env->isolate()), 1, &arg)
18031802
.IsEmpty()) {
@@ -1875,7 +1874,7 @@ MaybeLocal<Value> NativeCryptoKey::Create(Environment* env,
18751874
if (!KeyObjectHandle::Create(env, data).ToLocal(&handle)) return {};
18761875

18771876
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();
18791878
if (env->builtin_module_require()
18801879
->Call(context, Null(isolate), 1, &arg)
18811880
.IsEmpty()) {
@@ -2017,31 +2016,28 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20172016
}
20182017
CHECK(bundle_v->IsObject());
20192018
Local<Object> bundle = bundle_v.As<Object>();
2020-
Isolate* isolate = env()->isolate();
20212019
Local<Object> obj = object();
20222020

20232021
// The partially-initialized object produced by
20242022
// CryptoKeyTransferData::Deserialize should not have algorithm set yet.
20252023
CHECK(obj->GetInternalField(kAlgorithmField).As<Value>()->IsUndefined());
20262024

20272025
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)) {
20302027
return Nothing<void>();
20312028
}
20322029
CHECK(algorithm_v->IsObject());
20332030
obj->SetInternalField(kAlgorithmField, algorithm_v);
20342031

20352032
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)) {
20382034
return Nothing<void>();
20392035
}
20402036
CHECK(usages_v->IsUint32());
20412037
usages_mask_ = usages_v.As<Uint32>()->Value();
20422038

20432039
Local<Value> extractable_v;
2044-
if (!bundle->Get(context, FIXED_ONE_BYTE_STRING(isolate, "extractable"))
2040+
if (!bundle->Get(context, env()->extractable_string())
20452041
.ToLocal(&extractable_v)) {
20462042
return Nothing<void>();
20472043
}
@@ -2054,21 +2050,19 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20542050
Maybe<bool> NativeCryptoKey::CryptoKeyTransferData::FinalizeTransferWrite(
20552051
Local<Context> context, v8::ValueSerializer* serializer) {
20562052
Isolate* isolate = Isolate::GetCurrent();
2053+
Environment* env = Environment::GetCurrent(isolate);
20572054
CHECK(!algorithm_.IsEmpty());
20582055
Local<Object> bundle = Object::New(isolate);
20592056
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() ||
20642058
bundle
20652059
->Set(context,
2066-
FIXED_ONE_BYTE_STRING(isolate, "usages"),
2060+
env->usages_string(),
20672061
Uint32::NewFromUnsigned(isolate, usages_mask_))
20682062
.IsNothing() ||
20692063
bundle
20702064
->Set(context,
2071-
FIXED_ONE_BYTE_STRING(isolate, "extractable"),
2065+
env->extractable_string(),
20722066
v8::Boolean::New(isolate, extractable_))
20732067
.IsNothing()) {
20742068
return Nothing<bool>();
@@ -2094,7 +2088,7 @@ BaseObjectPtr<BaseObject> NativeCryptoKey::CryptoKeyTransferData::Deserialize(
20942088
// Make sure internal/crypto/keys has been loaded so that the
20952089
// CryptoKey constructor is registered with the Environment.
20962090
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();
20982092
if (env->builtin_module_require()
20992093
->Call(context, Null(isolate), 1, &arg)
21002094
.IsEmpty()) {

‎src/crypto/crypto_util.cc‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ MaybeLocal<Value> cryptoErrorListToException(Environment* env,
267267
// If there are no errors, it is likely a bug but we will return
268268
// an error anyway.
269269
if (errors.empty()) {
270-
returnException::Error(FIXED_ONE_BYTE_STRING(env->isolate(), "Ok"));
270+
returnException::Error(env->ok_string());
271271
}
272272

273273
// The last error in the list is the one that will be used as the
@@ -778,13 +778,9 @@ MaybeLocal<Value> CreateWebCryptoJobError(Environment* env,
778778
CHECK(domexception_ctor->IsFunction());
779779

780780
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())
785782
.IsNothing() ||
786-
options->Set(context, FIXED_ONE_BYTE_STRING(isolate, "cause"), cause)
787-
.IsNothing()) {
783+
options->Set(context, env->cause_string(), cause).IsNothing()) {
788784
return {};
789785
}
790786

‎src/crypto/crypto_util.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ class CryptoJob : public AsyncWrap, public ThreadPoolWork {
477477
{
478478
node::errors::TryCatchScope try_catch(env);
479479
if (value->IsObject()) {
480-
then_key = FIXED_ONE_BYTE_STRING(env->isolate(), "then");
480+
then_key = env->then_string();
481481
v8::Local<v8::Object> object = value.As<v8::Object>();
482482
v8::Maybe<bool> has_own_then =
483483
object->HasOwnProperty(context, then_key);

‎src/env_properties.h‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
V(__dirname_string, "__dirname") \
8383
V(ack_string, "ack") \
8484
V(address_string, "address") \
85+
V(algorithm_string, "algorithm") \
8586
V(aliases_string, "aliases") \
8687
V(allow_bare_named_params_string, "allowBareNamedParameters") \
8788
V(allow_unknown_named_params_string, "allowUnknownNamedParameters") \
@@ -93,13 +94,15 @@
9394
V(backup_string, "backup") \
9495
V(base_string, "base") \
9596
V(base_url_string, "baseURL") \
97+
V(brotli_string, "brotli") \
9698
V(buffer_string, "buffer") \
9799
V(bytes_parsed_string, "bytesParsed") \
98100
V(bytes_read_string, "bytesRead") \
99101
V(bytes_written_string, "bytesWritten") \
100102
V(cached_data_produced_string, "cachedDataProduced") \
101103
V(cached_data_rejected_string, "cachedDataRejected") \
102104
V(cached_data_string, "cachedData") \
105+
V(cause_string, "cause") \
103106
V(change_string, "change") \
104107
V(changes_string, "changes") \
105108
V(chunks_sent_since_last_write_string, "chunksSentSinceLastWrite") \
@@ -180,6 +183,7 @@
180183
V(exponent_string, "exponent") \
181184
V(exports_string, "exports") \
182185
V(external_stream_string, "_externalStream") \
186+
V(extractable_string, "extractable") \
183187
V(family_string, "family") \
184188
V(fatal_exception_string, "_fatalException") \
185189
V(fd_string, "fd") \
@@ -215,6 +219,7 @@
215219
V(ignore_string, "ignore") \
216220
V(inherit_string, "inherit") \
217221
V(input_string, "input") \
222+
V(internal_crypto_keys_string, "internal/crypto/keys") \
218223
V(inverse_string, "inverse") \
219224
V(ipv4_string, "IPv4") \
220225
V(ipv6_string, "IPv6") \
@@ -264,6 +269,7 @@
264269
V(node_string, "node") \
265270
V(object_string, "Object") \
266271
V(ocsp_request_string, "OCSPRequest") \
272+
V(ok_string, "ok") \
267273
V(oncertcb_string, "oncertcb") \
268274
V(onchange_string, "onchange") \
269275
V(onclienthello_string, "onclienthello") \
@@ -287,10 +293,14 @@
287293
V(onwrite_string, "onwrite") \
288294
V(ongracefulclosecomplete_string, "ongracefulclosecomplete") \
289295
V(openssl_error_stack, "opensslErrorStack") \
296+
V(operationerror_string, "OperationError") \
290297
V(options_string, "options") \
291298
V(original_string, "original") \
292299
V(output_string, "output") \
293300
V(overlapped_string, "overlapped") \
301+
V(p256_string, "P-256") \
302+
V(p384_string, "P-384") \
303+
V(p521_string, "P-521") \
294304
V(parse_error_string, "Parse Error") \
295305
V(password_string, "password") \
296306
V(path_string, "path") \
@@ -333,6 +343,7 @@
333343
V(return_arrays_string, "returnArrays") \
334344
V(return_string, "return") \
335345
V(salt_length_string, "saltLength") \
346+
V(secp256k1_string, "secp256k1") \
336347
V(search_string, "search") \
337348
V(servername_string, "servername") \
338349
V(session_id_string, "sessionId") \
@@ -361,6 +372,7 @@
361372
V(syscall_string, "syscall") \
362373
V(table_string, "table") \
363374
V(target_string, "target") \
375+
V(then_string, "then") \
364376
V(thread_id_string, "threadId") \
365377
V(thread_name_string, "threadName") \
366378
V(tls_group_string, "TLSGroup") \
@@ -379,6 +391,7 @@
379391
V(uid_string, "uid") \
380392
V(unknown_string, "<unknown>") \
381393
V(url_string, "url") \
394+
V(usages_string, "usages") \
382395
V(username_string, "username") \
383396
V(value_string, "value") \
384397
V(verify_error_string, "verifyError") \
@@ -388,7 +401,9 @@
388401
V(wrap_string, "wrap") \
389402
V(writable_string, "writable") \
390403
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")
392407

393408
#definePER_ISOLATE_TEMPLATE_PROPERTIES(V) \
394409
V(a_record_template, v8::DictionaryTemplate) \

‎src/node_ffi.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ Local<FunctionTemplate> DynamicLibrary::GetConstructorTemplate(
12101210
DynamicLibrary::kInternalFieldCount);
12111211

12121212
tmpl->InstanceTemplate()->SetAccessorProperty(
1213-
FIXED_ONE_BYTE_STRING(isolate, "path"),
1213+
env->path_string(),
12141214
FunctionTemplate::New(env->isolate(), DynamicLibrary::GetPath),
12151215
Local<FunctionTemplate>(),
12161216
attributes);

‎src/permission/permission.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ bool Permission::is_scope_granted(Environment* env,
265265
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
266266
constchar* perm_str = PermissionToString(permission);
267267
msg->Set(context,
268-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
268+
env->permission_string(),
269269
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
270270
.Check();
271271
msg->Set(context,
272-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
272+
env->resource_string(),
273273
v8::String::NewFromUtf8(isolate,
274274
res.data(),
275275
v8::NewStringType::kNormal,
@@ -335,11 +335,11 @@ void Permission::Drop(Environment* env,
335335
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
336336
constchar* perm_str = PermissionToString(scope);
337337
msg->Set(context,
338-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
338+
env->permission_string(),
339339
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
340340
.Check();
341341
msg->Set(context,
342-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
342+
env->resource_string(),
343343
v8::String::NewFromUtf8(isolate,
344344
param.data(),
345345
v8::NewStringType::kNormal,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Commit a293dbf

Browse files
jasnelladuh95
authored andcommitted
src: update repeated use strings to env
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #64760 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 3b8a0ba commit a293dbf

8 files changed

Lines changed: 42 additions & 40 deletions

File tree

‎src/crypto/crypto_context.cc‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,12 +2255,9 @@ void SecureContext::GetCertificateCompressionAlgorithms(
22552255
Environment* env = Environment::GetCurrent(args);
22562256
LocalVector<Value> algs(env->isolate());
22572257
#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());
22642261
#endif
22652262
args.GetReturnValue().Set(
22662263
Array::New(env->isolate(), algs.data(), algs.size()));

‎src/crypto/crypto_ec.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,16 +520,16 @@ bool ExportJWKEcKey(Environment* env,
520520
constint nid = EC_GROUP_get_curve_name(group);
521521
switch (nid) {
522522
case NID_X9_62_prime256v1:
523-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-256");
523+
crv_name = env->p256_string();
524524
break;
525525
case NID_secp256k1:
526-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "secp256k1");
526+
crv_name = env->secp256k1_string();
527527
break;
528528
case NID_secp384r1:
529-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-384");
529+
crv_name = env->p384_string();
530530
break;
531531
case NID_secp521r1:
532-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-521");
532+
crv_name = env->p521_string();
533533
break;
534534
default: {
535535
THROW_ERR_CRYPTO_JWK_UNSUPPORTED_CURVE(

‎src/crypto/crypto_keys.cc‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,8 +1796,7 @@ BaseObjectPtr<BaseObject> NativeKeyObject::KeyObjectTransferData::Deserialize(
17961796
return {};
17971797

17981798
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();
18011800
if (env->builtin_module_require()
18021801
->Call(context, Null(env->isolate()), 1, &arg)
18031802
.IsEmpty()) {
@@ -1875,7 +1874,7 @@ MaybeLocal<Value> NativeCryptoKey::Create(Environment* env,
18751874
if (!KeyObjectHandle::Create(env, data).ToLocal(&handle)) return {};
18761875

18771876
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();
18791878
if (env->builtin_module_require()
18801879
->Call(context, Null(isolate), 1, &arg)
18811880
.IsEmpty()) {
@@ -2017,31 +2016,28 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20172016
}
20182017
CHECK(bundle_v->IsObject());
20192018
Local<Object> bundle = bundle_v.As<Object>();
2020-
Isolate* isolate = env()->isolate();
20212019
Local<Object> obj = object();
20222020

20232021
// The partially-initialized object produced by
20242022
// CryptoKeyTransferData::Deserialize should not have algorithm set yet.
20252023
CHECK(obj->GetInternalField(kAlgorithmField).As<Value>()->IsUndefined());
20262024

20272025
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)) {
20302027
return Nothing<void>();
20312028
}
20322029
CHECK(algorithm_v->IsObject());
20332030
obj->SetInternalField(kAlgorithmField, algorithm_v);
20342031

20352032
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)) {
20382034
return Nothing<void>();
20392035
}
20402036
CHECK(usages_v->IsUint32());
20412037
usages_mask_ = usages_v.As<Uint32>()->Value();
20422038

20432039
Local<Value> extractable_v;
2044-
if (!bundle->Get(context, FIXED_ONE_BYTE_STRING(isolate, "extractable"))
2040+
if (!bundle->Get(context, env()->extractable_string())
20452041
.ToLocal(&extractable_v)) {
20462042
return Nothing<void>();
20472043
}
@@ -2054,21 +2050,19 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20542050
Maybe<bool> NativeCryptoKey::CryptoKeyTransferData::FinalizeTransferWrite(
20552051
Local<Context> context, v8::ValueSerializer* serializer) {
20562052
Isolate* isolate = Isolate::GetCurrent();
2053+
Environment* env = Environment::GetCurrent(isolate);
20572054
CHECK(!algorithm_.IsEmpty());
20582055
Local<Object> bundle = Object::New(isolate);
20592056
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() ||
20642058
bundle
20652059
->Set(context,
2066-
FIXED_ONE_BYTE_STRING(isolate, "usages"),
2060+
env->usages_string(),
20672061
Uint32::NewFromUnsigned(isolate, usages_mask_))
20682062
.IsNothing() ||
20692063
bundle
20702064
->Set(context,
2071-
FIXED_ONE_BYTE_STRING(isolate, "extractable"),
2065+
env->extractable_string(),
20722066
v8::Boolean::New(isolate, extractable_))
20732067
.IsNothing()) {
20742068
return Nothing<bool>();
@@ -2094,7 +2088,7 @@ BaseObjectPtr<BaseObject> NativeCryptoKey::CryptoKeyTransferData::Deserialize(
20942088
// Make sure internal/crypto/keys has been loaded so that the
20952089
// CryptoKey constructor is registered with the Environment.
20962090
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();
20982092
if (env->builtin_module_require()
20992093
->Call(context, Null(isolate), 1, &arg)
21002094
.IsEmpty()) {

‎src/crypto/crypto_util.cc‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ MaybeLocal<Value> cryptoErrorListToException(Environment* env,
267267
// If there are no errors, it is likely a bug but we will return
268268
// an error anyway.
269269
if (errors.empty()) {
270-
returnException::Error(FIXED_ONE_BYTE_STRING(env->isolate(), "Ok"));
270+
returnException::Error(env->ok_string());
271271
}
272272

273273
// The last error in the list is the one that will be used as the
@@ -778,13 +778,9 @@ MaybeLocal<Value> CreateWebCryptoJobError(Environment* env,
778778
CHECK(domexception_ctor->IsFunction());
779779

780780
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())
785782
.IsNothing() ||
786-
options->Set(context, FIXED_ONE_BYTE_STRING(isolate, "cause"), cause)
787-
.IsNothing()) {
783+
options->Set(context, env->cause_string(), cause).IsNothing()) {
788784
return {};
789785
}
790786

‎src/crypto/crypto_util.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ class CryptoJob : public AsyncWrap, public ThreadPoolWork {
477477
{
478478
node::errors::TryCatchScope try_catch(env);
479479
if (value->IsObject()) {
480-
then_key = FIXED_ONE_BYTE_STRING(env->isolate(), "then");
480+
then_key = env->then_string();
481481
v8::Local<v8::Object> object = value.As<v8::Object>();
482482
v8::Maybe<bool> has_own_then =
483483
object->HasOwnProperty(context, then_key);

‎src/env_properties.h‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
V(__dirname_string, "__dirname") \
8383
V(ack_string, "ack") \
8484
V(address_string, "address") \
85+
V(algorithm_string, "algorithm") \
8586
V(aliases_string, "aliases") \
8687
V(allow_bare_named_params_string, "allowBareNamedParameters") \
8788
V(allow_unknown_named_params_string, "allowUnknownNamedParameters") \
@@ -93,13 +94,15 @@
9394
V(backup_string, "backup") \
9495
V(base_string, "base") \
9596
V(base_url_string, "baseURL") \
97+
V(brotli_string, "brotli") \
9698
V(buffer_string, "buffer") \
9799
V(bytes_parsed_string, "bytesParsed") \
98100
V(bytes_read_string, "bytesRead") \
99101
V(bytes_written_string, "bytesWritten") \
100102
V(cached_data_produced_string, "cachedDataProduced") \
101103
V(cached_data_rejected_string, "cachedDataRejected") \
102104
V(cached_data_string, "cachedData") \
105+
V(cause_string, "cause") \
103106
V(change_string, "change") \
104107
V(changes_string, "changes") \
105108
V(chunks_sent_since_last_write_string, "chunksSentSinceLastWrite") \
@@ -180,6 +183,7 @@
180183
V(exponent_string, "exponent") \
181184
V(exports_string, "exports") \
182185
V(external_stream_string, "_externalStream") \
186+
V(extractable_string, "extractable") \
183187
V(family_string, "family") \
184188
V(fatal_exception_string, "_fatalException") \
185189
V(fd_string, "fd") \
@@ -215,6 +219,7 @@
215219
V(ignore_string, "ignore") \
216220
V(inherit_string, "inherit") \
217221
V(input_string, "input") \
222+
V(internal_crypto_keys_string, "internal/crypto/keys") \
218223
V(inverse_string, "inverse") \
219224
V(ipv4_string, "IPv4") \
220225
V(ipv6_string, "IPv6") \
@@ -264,6 +269,7 @@
264269
V(node_string, "node") \
265270
V(object_string, "Object") \
266271
V(ocsp_request_string, "OCSPRequest") \
272+
V(ok_string, "ok") \
267273
V(oncertcb_string, "oncertcb") \
268274
V(onchange_string, "onchange") \
269275
V(onclienthello_string, "onclienthello") \
@@ -287,10 +293,14 @@
287293
V(onwrite_string, "onwrite") \
288294
V(ongracefulclosecomplete_string, "ongracefulclosecomplete") \
289295
V(openssl_error_stack, "opensslErrorStack") \
296+
V(operationerror_string, "OperationError") \
290297
V(options_string, "options") \
291298
V(original_string, "original") \
292299
V(output_string, "output") \
293300
V(overlapped_string, "overlapped") \
301+
V(p256_string, "P-256") \
302+
V(p384_string, "P-384") \
303+
V(p521_string, "P-521") \
294304
V(parse_error_string, "Parse Error") \
295305
V(password_string, "password") \
296306
V(path_string, "path") \
@@ -333,6 +343,7 @@
333343
V(return_arrays_string, "returnArrays") \
334344
V(return_string, "return") \
335345
V(salt_length_string, "saltLength") \
346+
V(secp256k1_string, "secp256k1") \
336347
V(search_string, "search") \
337348
V(servername_string, "servername") \
338349
V(session_id_string, "sessionId") \
@@ -361,6 +372,7 @@
361372
V(syscall_string, "syscall") \
362373
V(table_string, "table") \
363374
V(target_string, "target") \
375+
V(then_string, "then") \
364376
V(thread_id_string, "threadId") \
365377
V(thread_name_string, "threadName") \
366378
V(tls_group_string, "TLSGroup") \
@@ -379,6 +391,7 @@
379391
V(uid_string, "uid") \
380392
V(unknown_string, "<unknown>") \
381393
V(url_string, "url") \
394+
V(usages_string, "usages") \
382395
V(username_string, "username") \
383396
V(value_string, "value") \
384397
V(verify_error_string, "verifyError") \
@@ -388,7 +401,9 @@
388401
V(wrap_string, "wrap") \
389402
V(writable_string, "writable") \
390403
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")
392407

393408
#definePER_ISOLATE_TEMPLATE_PROPERTIES(V) \
394409
V(a_record_template, v8::DictionaryTemplate) \

‎src/node_ffi.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ Local<FunctionTemplate> DynamicLibrary::GetConstructorTemplate(
12101210
DynamicLibrary::kInternalFieldCount);
12111211

12121212
tmpl->InstanceTemplate()->SetAccessorProperty(
1213-
FIXED_ONE_BYTE_STRING(isolate, "path"),
1213+
env->path_string(),
12141214
FunctionTemplate::New(env->isolate(), DynamicLibrary::GetPath),
12151215
Local<FunctionTemplate>(),
12161216
attributes);

‎src/permission/permission.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ bool Permission::is_scope_granted(Environment* env,
265265
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
266266
constchar* perm_str = PermissionToString(permission);
267267
msg->Set(context,
268-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
268+
env->permission_string(),
269269
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
270270
.Check();
271271
msg->Set(context,
272-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
272+
env->resource_string(),
273273
v8::String::NewFromUtf8(isolate,
274274
res.data(),
275275
v8::NewStringType::kNormal,
@@ -335,11 +335,11 @@ void Permission::Drop(Environment* env,
335335
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
336336
constchar* perm_str = PermissionToString(scope);
337337
msg->Set(context,
338-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
338+
env->permission_string(),
339339
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
340340
.Check();
341341
msg->Set(context,
342-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
342+
env->resource_string(),
343343
v8::String::NewFromUtf8(isolate,
344344
param.data(),
345345
v8::NewStringType::kNormal,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit a293dbf

Browse files
jasnelladuh95
authored andcommitted
src: update repeated use strings to env
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #64760 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 3b8a0ba commit a293dbf

8 files changed

Lines changed: 42 additions & 40 deletions

File tree

‎src/crypto/crypto_context.cc‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,12 +2255,9 @@ void SecureContext::GetCertificateCompressionAlgorithms(
22552255
Environment* env = Environment::GetCurrent(args);
22562256
LocalVector<Value> algs(env->isolate());
22572257
#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());
22642261
#endif
22652262
args.GetReturnValue().Set(
22662263
Array::New(env->isolate(), algs.data(), algs.size()));

‎src/crypto/crypto_ec.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,16 +520,16 @@ bool ExportJWKEcKey(Environment* env,
520520
constint nid = EC_GROUP_get_curve_name(group);
521521
switch (nid) {
522522
case NID_X9_62_prime256v1:
523-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-256");
523+
crv_name = env->p256_string();
524524
break;
525525
case NID_secp256k1:
526-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "secp256k1");
526+
crv_name = env->secp256k1_string();
527527
break;
528528
case NID_secp384r1:
529-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-384");
529+
crv_name = env->p384_string();
530530
break;
531531
case NID_secp521r1:
532-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-521");
532+
crv_name = env->p521_string();
533533
break;
534534
default: {
535535
THROW_ERR_CRYPTO_JWK_UNSUPPORTED_CURVE(

‎src/crypto/crypto_keys.cc‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,8 +1796,7 @@ BaseObjectPtr<BaseObject> NativeKeyObject::KeyObjectTransferData::Deserialize(
17961796
return {};
17971797

17981798
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();
18011800
if (env->builtin_module_require()
18021801
->Call(context, Null(env->isolate()), 1, &arg)
18031802
.IsEmpty()) {
@@ -1875,7 +1874,7 @@ MaybeLocal<Value> NativeCryptoKey::Create(Environment* env,
18751874
if (!KeyObjectHandle::Create(env, data).ToLocal(&handle)) return {};
18761875

18771876
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();
18791878
if (env->builtin_module_require()
18801879
->Call(context, Null(isolate), 1, &arg)
18811880
.IsEmpty()) {
@@ -2017,31 +2016,28 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20172016
}
20182017
CHECK(bundle_v->IsObject());
20192018
Local<Object> bundle = bundle_v.As<Object>();
2020-
Isolate* isolate = env()->isolate();
20212019
Local<Object> obj = object();
20222020

20232021
// The partially-initialized object produced by
20242022
// CryptoKeyTransferData::Deserialize should not have algorithm set yet.
20252023
CHECK(obj->GetInternalField(kAlgorithmField).As<Value>()->IsUndefined());
20262024

20272025
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)) {
20302027
return Nothing<void>();
20312028
}
20322029
CHECK(algorithm_v->IsObject());
20332030
obj->SetInternalField(kAlgorithmField, algorithm_v);
20342031

20352032
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)) {
20382034
return Nothing<void>();
20392035
}
20402036
CHECK(usages_v->IsUint32());
20412037
usages_mask_ = usages_v.As<Uint32>()->Value();
20422038

20432039
Local<Value> extractable_v;
2044-
if (!bundle->Get(context, FIXED_ONE_BYTE_STRING(isolate, "extractable"))
2040+
if (!bundle->Get(context, env()->extractable_string())
20452041
.ToLocal(&extractable_v)) {
20462042
return Nothing<void>();
20472043
}
@@ -2054,21 +2050,19 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20542050
Maybe<bool> NativeCryptoKey::CryptoKeyTransferData::FinalizeTransferWrite(
20552051
Local<Context> context, v8::ValueSerializer* serializer) {
20562052
Isolate* isolate = Isolate::GetCurrent();
2053+
Environment* env = Environment::GetCurrent(isolate);
20572054
CHECK(!algorithm_.IsEmpty());
20582055
Local<Object> bundle = Object::New(isolate);
20592056
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() ||
20642058
bundle
20652059
->Set(context,
2066-
FIXED_ONE_BYTE_STRING(isolate, "usages"),
2060+
env->usages_string(),
20672061
Uint32::NewFromUnsigned(isolate, usages_mask_))
20682062
.IsNothing() ||
20692063
bundle
20702064
->Set(context,
2071-
FIXED_ONE_BYTE_STRING(isolate, "extractable"),
2065+
env->extractable_string(),
20722066
v8::Boolean::New(isolate, extractable_))
20732067
.IsNothing()) {
20742068
return Nothing<bool>();
@@ -2094,7 +2088,7 @@ BaseObjectPtr<BaseObject> NativeCryptoKey::CryptoKeyTransferData::Deserialize(
20942088
// Make sure internal/crypto/keys has been loaded so that the
20952089
// CryptoKey constructor is registered with the Environment.
20962090
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();
20982092
if (env->builtin_module_require()
20992093
->Call(context, Null(isolate), 1, &arg)
21002094
.IsEmpty()) {

‎src/crypto/crypto_util.cc‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ MaybeLocal<Value> cryptoErrorListToException(Environment* env,
267267
// If there are no errors, it is likely a bug but we will return
268268
// an error anyway.
269269
if (errors.empty()) {
270-
returnException::Error(FIXED_ONE_BYTE_STRING(env->isolate(), "Ok"));
270+
returnException::Error(env->ok_string());
271271
}
272272

273273
// The last error in the list is the one that will be used as the
@@ -778,13 +778,9 @@ MaybeLocal<Value> CreateWebCryptoJobError(Environment* env,
778778
CHECK(domexception_ctor->IsFunction());
779779

780780
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())
785782
.IsNothing() ||
786-
options->Set(context, FIXED_ONE_BYTE_STRING(isolate, "cause"), cause)
787-
.IsNothing()) {
783+
options->Set(context, env->cause_string(), cause).IsNothing()) {
788784
return {};
789785
}
790786

‎src/crypto/crypto_util.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ class CryptoJob : public AsyncWrap, public ThreadPoolWork {
477477
{
478478
node::errors::TryCatchScope try_catch(env);
479479
if (value->IsObject()) {
480-
then_key = FIXED_ONE_BYTE_STRING(env->isolate(), "then");
480+
then_key = env->then_string();
481481
v8::Local<v8::Object> object = value.As<v8::Object>();
482482
v8::Maybe<bool> has_own_then =
483483
object->HasOwnProperty(context, then_key);

‎src/env_properties.h‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
V(__dirname_string, "__dirname") \
8383
V(ack_string, "ack") \
8484
V(address_string, "address") \
85+
V(algorithm_string, "algorithm") \
8586
V(aliases_string, "aliases") \
8687
V(allow_bare_named_params_string, "allowBareNamedParameters") \
8788
V(allow_unknown_named_params_string, "allowUnknownNamedParameters") \
@@ -93,13 +94,15 @@
9394
V(backup_string, "backup") \
9495
V(base_string, "base") \
9596
V(base_url_string, "baseURL") \
97+
V(brotli_string, "brotli") \
9698
V(buffer_string, "buffer") \
9799
V(bytes_parsed_string, "bytesParsed") \
98100
V(bytes_read_string, "bytesRead") \
99101
V(bytes_written_string, "bytesWritten") \
100102
V(cached_data_produced_string, "cachedDataProduced") \
101103
V(cached_data_rejected_string, "cachedDataRejected") \
102104
V(cached_data_string, "cachedData") \
105+
V(cause_string, "cause") \
103106
V(change_string, "change") \
104107
V(changes_string, "changes") \
105108
V(chunks_sent_since_last_write_string, "chunksSentSinceLastWrite") \
@@ -180,6 +183,7 @@
180183
V(exponent_string, "exponent") \
181184
V(exports_string, "exports") \
182185
V(external_stream_string, "_externalStream") \
186+
V(extractable_string, "extractable") \
183187
V(family_string, "family") \
184188
V(fatal_exception_string, "_fatalException") \
185189
V(fd_string, "fd") \
@@ -215,6 +219,7 @@
215219
V(ignore_string, "ignore") \
216220
V(inherit_string, "inherit") \
217221
V(input_string, "input") \
222+
V(internal_crypto_keys_string, "internal/crypto/keys") \
218223
V(inverse_string, "inverse") \
219224
V(ipv4_string, "IPv4") \
220225
V(ipv6_string, "IPv6") \
@@ -264,6 +269,7 @@
264269
V(node_string, "node") \
265270
V(object_string, "Object") \
266271
V(ocsp_request_string, "OCSPRequest") \
272+
V(ok_string, "ok") \
267273
V(oncertcb_string, "oncertcb") \
268274
V(onchange_string, "onchange") \
269275
V(onclienthello_string, "onclienthello") \
@@ -287,10 +293,14 @@
287293
V(onwrite_string, "onwrite") \
288294
V(ongracefulclosecomplete_string, "ongracefulclosecomplete") \
289295
V(openssl_error_stack, "opensslErrorStack") \
296+
V(operationerror_string, "OperationError") \
290297
V(options_string, "options") \
291298
V(original_string, "original") \
292299
V(output_string, "output") \
293300
V(overlapped_string, "overlapped") \
301+
V(p256_string, "P-256") \
302+
V(p384_string, "P-384") \
303+
V(p521_string, "P-521") \
294304
V(parse_error_string, "Parse Error") \
295305
V(password_string, "password") \
296306
V(path_string, "path") \
@@ -333,6 +343,7 @@
333343
V(return_arrays_string, "returnArrays") \
334344
V(return_string, "return") \
335345
V(salt_length_string, "saltLength") \
346+
V(secp256k1_string, "secp256k1") \
336347
V(search_string, "search") \
337348
V(servername_string, "servername") \
338349
V(session_id_string, "sessionId") \
@@ -361,6 +372,7 @@
361372
V(syscall_string, "syscall") \
362373
V(table_string, "table") \
363374
V(target_string, "target") \
375+
V(then_string, "then") \
364376
V(thread_id_string, "threadId") \
365377
V(thread_name_string, "threadName") \
366378
V(tls_group_string, "TLSGroup") \
@@ -379,6 +391,7 @@
379391
V(uid_string, "uid") \
380392
V(unknown_string, "<unknown>") \
381393
V(url_string, "url") \
394+
V(usages_string, "usages") \
382395
V(username_string, "username") \
383396
V(value_string, "value") \
384397
V(verify_error_string, "verifyError") \
@@ -388,7 +401,9 @@
388401
V(wrap_string, "wrap") \
389402
V(writable_string, "writable") \
390403
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")
392407

393408
#definePER_ISOLATE_TEMPLATE_PROPERTIES(V) \
394409
V(a_record_template, v8::DictionaryTemplate) \

‎src/node_ffi.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ Local<FunctionTemplate> DynamicLibrary::GetConstructorTemplate(
12101210
DynamicLibrary::kInternalFieldCount);
12111211

12121212
tmpl->InstanceTemplate()->SetAccessorProperty(
1213-
FIXED_ONE_BYTE_STRING(isolate, "path"),
1213+
env->path_string(),
12141214
FunctionTemplate::New(env->isolate(), DynamicLibrary::GetPath),
12151215
Local<FunctionTemplate>(),
12161216
attributes);

‎src/permission/permission.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ bool Permission::is_scope_granted(Environment* env,
265265
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
266266
constchar* perm_str = PermissionToString(permission);
267267
msg->Set(context,
268-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
268+
env->permission_string(),
269269
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
270270
.Check();
271271
msg->Set(context,
272-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
272+
env->resource_string(),
273273
v8::String::NewFromUtf8(isolate,
274274
res.data(),
275275
v8::NewStringType::kNormal,
@@ -335,11 +335,11 @@ void Permission::Drop(Environment* env,
335335
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
336336
constchar* perm_str = PermissionToString(scope);
337337
msg->Set(context,
338-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
338+
env->permission_string(),
339339
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
340340
.Check();
341341
msg->Set(context,
342-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
342+
env->resource_string(),
343343
v8::String::NewFromUtf8(isolate,
344344
param.data(),
345345
v8::NewStringType::kNormal,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit a293dbf

Browse files
jasnelladuh95
authored andcommitted
src: update repeated use strings to env
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #64760 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 3b8a0ba commit a293dbf

8 files changed

Lines changed: 42 additions & 40 deletions

File tree

‎src/crypto/crypto_context.cc‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,12 +2255,9 @@ void SecureContext::GetCertificateCompressionAlgorithms(
22552255
Environment* env = Environment::GetCurrent(args);
22562256
LocalVector<Value> algs(env->isolate());
22572257
#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());
22642261
#endif
22652262
args.GetReturnValue().Set(
22662263
Array::New(env->isolate(), algs.data(), algs.size()));

‎src/crypto/crypto_ec.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,16 +520,16 @@ bool ExportJWKEcKey(Environment* env,
520520
constint nid = EC_GROUP_get_curve_name(group);
521521
switch (nid) {
522522
case NID_X9_62_prime256v1:
523-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-256");
523+
crv_name = env->p256_string();
524524
break;
525525
case NID_secp256k1:
526-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "secp256k1");
526+
crv_name = env->secp256k1_string();
527527
break;
528528
case NID_secp384r1:
529-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-384");
529+
crv_name = env->p384_string();
530530
break;
531531
case NID_secp521r1:
532-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-521");
532+
crv_name = env->p521_string();
533533
break;
534534
default: {
535535
THROW_ERR_CRYPTO_JWK_UNSUPPORTED_CURVE(

‎src/crypto/crypto_keys.cc‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,8 +1796,7 @@ BaseObjectPtr<BaseObject> NativeKeyObject::KeyObjectTransferData::Deserialize(
17961796
return {};
17971797

17981798
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();
18011800
if (env->builtin_module_require()
18021801
->Call(context, Null(env->isolate()), 1, &arg)
18031802
.IsEmpty()) {
@@ -1875,7 +1874,7 @@ MaybeLocal<Value> NativeCryptoKey::Create(Environment* env,
18751874
if (!KeyObjectHandle::Create(env, data).ToLocal(&handle)) return {};
18761875

18771876
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();
18791878
if (env->builtin_module_require()
18801879
->Call(context, Null(isolate), 1, &arg)
18811880
.IsEmpty()) {
@@ -2017,31 +2016,28 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20172016
}
20182017
CHECK(bundle_v->IsObject());
20192018
Local<Object> bundle = bundle_v.As<Object>();
2020-
Isolate* isolate = env()->isolate();
20212019
Local<Object> obj = object();
20222020

20232021
// The partially-initialized object produced by
20242022
// CryptoKeyTransferData::Deserialize should not have algorithm set yet.
20252023
CHECK(obj->GetInternalField(kAlgorithmField).As<Value>()->IsUndefined());
20262024

20272025
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)) {
20302027
return Nothing<void>();
20312028
}
20322029
CHECK(algorithm_v->IsObject());
20332030
obj->SetInternalField(kAlgorithmField, algorithm_v);
20342031

20352032
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)) {
20382034
return Nothing<void>();
20392035
}
20402036
CHECK(usages_v->IsUint32());
20412037
usages_mask_ = usages_v.As<Uint32>()->Value();
20422038

20432039
Local<Value> extractable_v;
2044-
if (!bundle->Get(context, FIXED_ONE_BYTE_STRING(isolate, "extractable"))
2040+
if (!bundle->Get(context, env()->extractable_string())
20452041
.ToLocal(&extractable_v)) {
20462042
return Nothing<void>();
20472043
}
@@ -2054,21 +2050,19 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20542050
Maybe<bool> NativeCryptoKey::CryptoKeyTransferData::FinalizeTransferWrite(
20552051
Local<Context> context, v8::ValueSerializer* serializer) {
20562052
Isolate* isolate = Isolate::GetCurrent();
2053+
Environment* env = Environment::GetCurrent(isolate);
20572054
CHECK(!algorithm_.IsEmpty());
20582055
Local<Object> bundle = Object::New(isolate);
20592056
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() ||
20642058
bundle
20652059
->Set(context,
2066-
FIXED_ONE_BYTE_STRING(isolate, "usages"),
2060+
env->usages_string(),
20672061
Uint32::NewFromUnsigned(isolate, usages_mask_))
20682062
.IsNothing() ||
20692063
bundle
20702064
->Set(context,
2071-
FIXED_ONE_BYTE_STRING(isolate, "extractable"),
2065+
env->extractable_string(),
20722066
v8::Boolean::New(isolate, extractable_))
20732067
.IsNothing()) {
20742068
return Nothing<bool>();
@@ -2094,7 +2088,7 @@ BaseObjectPtr<BaseObject> NativeCryptoKey::CryptoKeyTransferData::Deserialize(
20942088
// Make sure internal/crypto/keys has been loaded so that the
20952089
// CryptoKey constructor is registered with the Environment.
20962090
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();
20982092
if (env->builtin_module_require()
20992093
->Call(context, Null(isolate), 1, &arg)
21002094
.IsEmpty()) {

‎src/crypto/crypto_util.cc‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ MaybeLocal<Value> cryptoErrorListToException(Environment* env,
267267
// If there are no errors, it is likely a bug but we will return
268268
// an error anyway.
269269
if (errors.empty()) {
270-
returnException::Error(FIXED_ONE_BYTE_STRING(env->isolate(), "Ok"));
270+
returnException::Error(env->ok_string());
271271
}
272272

273273
// The last error in the list is the one that will be used as the
@@ -778,13 +778,9 @@ MaybeLocal<Value> CreateWebCryptoJobError(Environment* env,
778778
CHECK(domexception_ctor->IsFunction());
779779

780780
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())
785782
.IsNothing() ||
786-
options->Set(context, FIXED_ONE_BYTE_STRING(isolate, "cause"), cause)
787-
.IsNothing()) {
783+
options->Set(context, env->cause_string(), cause).IsNothing()) {
788784
return {};
789785
}
790786

‎src/crypto/crypto_util.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ class CryptoJob : public AsyncWrap, public ThreadPoolWork {
477477
{
478478
node::errors::TryCatchScope try_catch(env);
479479
if (value->IsObject()) {
480-
then_key = FIXED_ONE_BYTE_STRING(env->isolate(), "then");
480+
then_key = env->then_string();
481481
v8::Local<v8::Object> object = value.As<v8::Object>();
482482
v8::Maybe<bool> has_own_then =
483483
object->HasOwnProperty(context, then_key);

‎src/env_properties.h‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
V(__dirname_string, "__dirname") \
8383
V(ack_string, "ack") \
8484
V(address_string, "address") \
85+
V(algorithm_string, "algorithm") \
8586
V(aliases_string, "aliases") \
8687
V(allow_bare_named_params_string, "allowBareNamedParameters") \
8788
V(allow_unknown_named_params_string, "allowUnknownNamedParameters") \
@@ -93,13 +94,15 @@
9394
V(backup_string, "backup") \
9495
V(base_string, "base") \
9596
V(base_url_string, "baseURL") \
97+
V(brotli_string, "brotli") \
9698
V(buffer_string, "buffer") \
9799
V(bytes_parsed_string, "bytesParsed") \
98100
V(bytes_read_string, "bytesRead") \
99101
V(bytes_written_string, "bytesWritten") \
100102
V(cached_data_produced_string, "cachedDataProduced") \
101103
V(cached_data_rejected_string, "cachedDataRejected") \
102104
V(cached_data_string, "cachedData") \
105+
V(cause_string, "cause") \
103106
V(change_string, "change") \
104107
V(changes_string, "changes") \
105108
V(chunks_sent_since_last_write_string, "chunksSentSinceLastWrite") \
@@ -180,6 +183,7 @@
180183
V(exponent_string, "exponent") \
181184
V(exports_string, "exports") \
182185
V(external_stream_string, "_externalStream") \
186+
V(extractable_string, "extractable") \
183187
V(family_string, "family") \
184188
V(fatal_exception_string, "_fatalException") \
185189
V(fd_string, "fd") \
@@ -215,6 +219,7 @@
215219
V(ignore_string, "ignore") \
216220
V(inherit_string, "inherit") \
217221
V(input_string, "input") \
222+
V(internal_crypto_keys_string, "internal/crypto/keys") \
218223
V(inverse_string, "inverse") \
219224
V(ipv4_string, "IPv4") \
220225
V(ipv6_string, "IPv6") \
@@ -264,6 +269,7 @@
264269
V(node_string, "node") \
265270
V(object_string, "Object") \
266271
V(ocsp_request_string, "OCSPRequest") \
272+
V(ok_string, "ok") \
267273
V(oncertcb_string, "oncertcb") \
268274
V(onchange_string, "onchange") \
269275
V(onclienthello_string, "onclienthello") \
@@ -287,10 +293,14 @@
287293
V(onwrite_string, "onwrite") \
288294
V(ongracefulclosecomplete_string, "ongracefulclosecomplete") \
289295
V(openssl_error_stack, "opensslErrorStack") \
296+
V(operationerror_string, "OperationError") \
290297
V(options_string, "options") \
291298
V(original_string, "original") \
292299
V(output_string, "output") \
293300
V(overlapped_string, "overlapped") \
301+
V(p256_string, "P-256") \
302+
V(p384_string, "P-384") \
303+
V(p521_string, "P-521") \
294304
V(parse_error_string, "Parse Error") \
295305
V(password_string, "password") \
296306
V(path_string, "path") \
@@ -333,6 +343,7 @@
333343
V(return_arrays_string, "returnArrays") \
334344
V(return_string, "return") \
335345
V(salt_length_string, "saltLength") \
346+
V(secp256k1_string, "secp256k1") \
336347
V(search_string, "search") \
337348
V(servername_string, "servername") \
338349
V(session_id_string, "sessionId") \
@@ -361,6 +372,7 @@
361372
V(syscall_string, "syscall") \
362373
V(table_string, "table") \
363374
V(target_string, "target") \
375+
V(then_string, "then") \
364376
V(thread_id_string, "threadId") \
365377
V(thread_name_string, "threadName") \
366378
V(tls_group_string, "TLSGroup") \
@@ -379,6 +391,7 @@
379391
V(uid_string, "uid") \
380392
V(unknown_string, "<unknown>") \
381393
V(url_string, "url") \
394+
V(usages_string, "usages") \
382395
V(username_string, "username") \
383396
V(value_string, "value") \
384397
V(verify_error_string, "verifyError") \
@@ -388,7 +401,9 @@
388401
V(wrap_string, "wrap") \
389402
V(writable_string, "writable") \
390403
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")
392407

393408
#definePER_ISOLATE_TEMPLATE_PROPERTIES(V) \
394409
V(a_record_template, v8::DictionaryTemplate) \

‎src/node_ffi.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ Local<FunctionTemplate> DynamicLibrary::GetConstructorTemplate(
12101210
DynamicLibrary::kInternalFieldCount);
12111211

12121212
tmpl->InstanceTemplate()->SetAccessorProperty(
1213-
FIXED_ONE_BYTE_STRING(isolate, "path"),
1213+
env->path_string(),
12141214
FunctionTemplate::New(env->isolate(), DynamicLibrary::GetPath),
12151215
Local<FunctionTemplate>(),
12161216
attributes);

‎src/permission/permission.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ bool Permission::is_scope_granted(Environment* env,
265265
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
266266
constchar* perm_str = PermissionToString(permission);
267267
msg->Set(context,
268-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
268+
env->permission_string(),
269269
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
270270
.Check();
271271
msg->Set(context,
272-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
272+
env->resource_string(),
273273
v8::String::NewFromUtf8(isolate,
274274
res.data(),
275275
v8::NewStringType::kNormal,
@@ -335,11 +335,11 @@ void Permission::Drop(Environment* env,
335335
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
336336
constchar* perm_str = PermissionToString(scope);
337337
msg->Set(context,
338-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
338+
env->permission_string(),
339339
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
340340
.Check();
341341
msg->Set(context,
342-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
342+
env->resource_string(),
343343
v8::String::NewFromUtf8(isolate,
344344
param.data(),
345345
v8::NewStringType::kNormal,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Commit a293dbf

Browse files
jasnelladuh95
authored andcommitted
src: update repeated use strings to env
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #64760 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 3b8a0ba commit a293dbf

8 files changed

Lines changed: 42 additions & 40 deletions

File tree

‎src/crypto/crypto_context.cc‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,12 +2255,9 @@ void SecureContext::GetCertificateCompressionAlgorithms(
22552255
Environment* env = Environment::GetCurrent(args);
22562256
LocalVector<Value> algs(env->isolate());
22572257
#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());
22642261
#endif
22652262
args.GetReturnValue().Set(
22662263
Array::New(env->isolate(), algs.data(), algs.size()));

‎src/crypto/crypto_ec.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,16 +520,16 @@ bool ExportJWKEcKey(Environment* env,
520520
constint nid = EC_GROUP_get_curve_name(group);
521521
switch (nid) {
522522
case NID_X9_62_prime256v1:
523-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-256");
523+
crv_name = env->p256_string();
524524
break;
525525
case NID_secp256k1:
526-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "secp256k1");
526+
crv_name = env->secp256k1_string();
527527
break;
528528
case NID_secp384r1:
529-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-384");
529+
crv_name = env->p384_string();
530530
break;
531531
case NID_secp521r1:
532-
crv_name = FIXED_ONE_BYTE_STRING(env->isolate(), "P-521");
532+
crv_name = env->p521_string();
533533
break;
534534
default: {
535535
THROW_ERR_CRYPTO_JWK_UNSUPPORTED_CURVE(

‎src/crypto/crypto_keys.cc‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,8 +1796,7 @@ BaseObjectPtr<BaseObject> NativeKeyObject::KeyObjectTransferData::Deserialize(
17961796
return {};
17971797

17981798
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();
18011800
if (env->builtin_module_require()
18021801
->Call(context, Null(env->isolate()), 1, &arg)
18031802
.IsEmpty()) {
@@ -1875,7 +1874,7 @@ MaybeLocal<Value> NativeCryptoKey::Create(Environment* env,
18751874
if (!KeyObjectHandle::Create(env, data).ToLocal(&handle)) return {};
18761875

18771876
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();
18791878
if (env->builtin_module_require()
18801879
->Call(context, Null(isolate), 1, &arg)
18811880
.IsEmpty()) {
@@ -2017,31 +2016,28 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20172016
}
20182017
CHECK(bundle_v->IsObject());
20192018
Local<Object> bundle = bundle_v.As<Object>();
2020-
Isolate* isolate = env()->isolate();
20212019
Local<Object> obj = object();
20222020

20232021
// The partially-initialized object produced by
20242022
// CryptoKeyTransferData::Deserialize should not have algorithm set yet.
20252023
CHECK(obj->GetInternalField(kAlgorithmField).As<Value>()->IsUndefined());
20262024

20272025
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)) {
20302027
return Nothing<void>();
20312028
}
20322029
CHECK(algorithm_v->IsObject());
20332030
obj->SetInternalField(kAlgorithmField, algorithm_v);
20342031

20352032
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)) {
20382034
return Nothing<void>();
20392035
}
20402036
CHECK(usages_v->IsUint32());
20412037
usages_mask_ = usages_v.As<Uint32>()->Value();
20422038

20432039
Local<Value> extractable_v;
2044-
if (!bundle->Get(context, FIXED_ONE_BYTE_STRING(isolate, "extractable"))
2040+
if (!bundle->Get(context, env()->extractable_string())
20452041
.ToLocal(&extractable_v)) {
20462042
return Nothing<void>();
20472043
}
@@ -2054,21 +2050,19 @@ Maybe<void> NativeCryptoKey::FinalizeTransferRead(
20542050
Maybe<bool> NativeCryptoKey::CryptoKeyTransferData::FinalizeTransferWrite(
20552051
Local<Context> context, v8::ValueSerializer* serializer) {
20562052
Isolate* isolate = Isolate::GetCurrent();
2053+
Environment* env = Environment::GetCurrent(isolate);
20572054
CHECK(!algorithm_.IsEmpty());
20582055
Local<Object> bundle = Object::New(isolate);
20592056
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() ||
20642058
bundle
20652059
->Set(context,
2066-
FIXED_ONE_BYTE_STRING(isolate, "usages"),
2060+
env->usages_string(),
20672061
Uint32::NewFromUnsigned(isolate, usages_mask_))
20682062
.IsNothing() ||
20692063
bundle
20702064
->Set(context,
2071-
FIXED_ONE_BYTE_STRING(isolate, "extractable"),
2065+
env->extractable_string(),
20722066
v8::Boolean::New(isolate, extractable_))
20732067
.IsNothing()) {
20742068
return Nothing<bool>();
@@ -2094,7 +2088,7 @@ BaseObjectPtr<BaseObject> NativeCryptoKey::CryptoKeyTransferData::Deserialize(
20942088
// Make sure internal/crypto/keys has been loaded so that the
20952089
// CryptoKey constructor is registered with the Environment.
20962090
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();
20982092
if (env->builtin_module_require()
20992093
->Call(context, Null(isolate), 1, &arg)
21002094
.IsEmpty()) {

‎src/crypto/crypto_util.cc‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ MaybeLocal<Value> cryptoErrorListToException(Environment* env,
267267
// If there are no errors, it is likely a bug but we will return
268268
// an error anyway.
269269
if (errors.empty()) {
270-
returnException::Error(FIXED_ONE_BYTE_STRING(env->isolate(), "Ok"));
270+
returnException::Error(env->ok_string());
271271
}
272272

273273
// The last error in the list is the one that will be used as the
@@ -778,13 +778,9 @@ MaybeLocal<Value> CreateWebCryptoJobError(Environment* env,
778778
CHECK(domexception_ctor->IsFunction());
779779

780780
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())
785782
.IsNothing() ||
786-
options->Set(context, FIXED_ONE_BYTE_STRING(isolate, "cause"), cause)
787-
.IsNothing()) {
783+
options->Set(context, env->cause_string(), cause).IsNothing()) {
788784
return {};
789785
}
790786

‎src/crypto/crypto_util.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ class CryptoJob : public AsyncWrap, public ThreadPoolWork {
477477
{
478478
node::errors::TryCatchScope try_catch(env);
479479
if (value->IsObject()) {
480-
then_key = FIXED_ONE_BYTE_STRING(env->isolate(), "then");
480+
then_key = env->then_string();
481481
v8::Local<v8::Object> object = value.As<v8::Object>();
482482
v8::Maybe<bool> has_own_then =
483483
object->HasOwnProperty(context, then_key);

‎src/env_properties.h‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
V(__dirname_string, "__dirname") \
8383
V(ack_string, "ack") \
8484
V(address_string, "address") \
85+
V(algorithm_string, "algorithm") \
8586
V(aliases_string, "aliases") \
8687
V(allow_bare_named_params_string, "allowBareNamedParameters") \
8788
V(allow_unknown_named_params_string, "allowUnknownNamedParameters") \
@@ -93,13 +94,15 @@
9394
V(backup_string, "backup") \
9495
V(base_string, "base") \
9596
V(base_url_string, "baseURL") \
97+
V(brotli_string, "brotli") \
9698
V(buffer_string, "buffer") \
9799
V(bytes_parsed_string, "bytesParsed") \
98100
V(bytes_read_string, "bytesRead") \
99101
V(bytes_written_string, "bytesWritten") \
100102
V(cached_data_produced_string, "cachedDataProduced") \
101103
V(cached_data_rejected_string, "cachedDataRejected") \
102104
V(cached_data_string, "cachedData") \
105+
V(cause_string, "cause") \
103106
V(change_string, "change") \
104107
V(changes_string, "changes") \
105108
V(chunks_sent_since_last_write_string, "chunksSentSinceLastWrite") \
@@ -180,6 +183,7 @@
180183
V(exponent_string, "exponent") \
181184
V(exports_string, "exports") \
182185
V(external_stream_string, "_externalStream") \
186+
V(extractable_string, "extractable") \
183187
V(family_string, "family") \
184188
V(fatal_exception_string, "_fatalException") \
185189
V(fd_string, "fd") \
@@ -215,6 +219,7 @@
215219
V(ignore_string, "ignore") \
216220
V(inherit_string, "inherit") \
217221
V(input_string, "input") \
222+
V(internal_crypto_keys_string, "internal/crypto/keys") \
218223
V(inverse_string, "inverse") \
219224
V(ipv4_string, "IPv4") \
220225
V(ipv6_string, "IPv6") \
@@ -264,6 +269,7 @@
264269
V(node_string, "node") \
265270
V(object_string, "Object") \
266271
V(ocsp_request_string, "OCSPRequest") \
272+
V(ok_string, "ok") \
267273
V(oncertcb_string, "oncertcb") \
268274
V(onchange_string, "onchange") \
269275
V(onclienthello_string, "onclienthello") \
@@ -287,10 +293,14 @@
287293
V(onwrite_string, "onwrite") \
288294
V(ongracefulclosecomplete_string, "ongracefulclosecomplete") \
289295
V(openssl_error_stack, "opensslErrorStack") \
296+
V(operationerror_string, "OperationError") \
290297
V(options_string, "options") \
291298
V(original_string, "original") \
292299
V(output_string, "output") \
293300
V(overlapped_string, "overlapped") \
301+
V(p256_string, "P-256") \
302+
V(p384_string, "P-384") \
303+
V(p521_string, "P-521") \
294304
V(parse_error_string, "Parse Error") \
295305
V(password_string, "password") \
296306
V(path_string, "path") \
@@ -333,6 +343,7 @@
333343
V(return_arrays_string, "returnArrays") \
334344
V(return_string, "return") \
335345
V(salt_length_string, "saltLength") \
346+
V(secp256k1_string, "secp256k1") \
336347
V(search_string, "search") \
337348
V(servername_string, "servername") \
338349
V(session_id_string, "sessionId") \
@@ -361,6 +372,7 @@
361372
V(syscall_string, "syscall") \
362373
V(table_string, "table") \
363374
V(target_string, "target") \
375+
V(then_string, "then") \
364376
V(thread_id_string, "threadId") \
365377
V(thread_name_string, "threadName") \
366378
V(tls_group_string, "TLSGroup") \
@@ -379,6 +391,7 @@
379391
V(uid_string, "uid") \
380392
V(unknown_string, "<unknown>") \
381393
V(url_string, "url") \
394+
V(usages_string, "usages") \
382395
V(username_string, "username") \
383396
V(value_string, "value") \
384397
V(verify_error_string, "verifyError") \
@@ -388,7 +401,9 @@
388401
V(wrap_string, "wrap") \
389402
V(writable_string, "writable") \
390403
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")
392407

393408
#definePER_ISOLATE_TEMPLATE_PROPERTIES(V) \
394409
V(a_record_template, v8::DictionaryTemplate) \

‎src/node_ffi.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ Local<FunctionTemplate> DynamicLibrary::GetConstructorTemplate(
12101210
DynamicLibrary::kInternalFieldCount);
12111211

12121212
tmpl->InstanceTemplate()->SetAccessorProperty(
1213-
FIXED_ONE_BYTE_STRING(isolate, "path"),
1213+
env->path_string(),
12141214
FunctionTemplate::New(env->isolate(), DynamicLibrary::GetPath),
12151215
Local<FunctionTemplate>(),
12161216
attributes);

‎src/permission/permission.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ bool Permission::is_scope_granted(Environment* env,
265265
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
266266
constchar* perm_str = PermissionToString(permission);
267267
msg->Set(context,
268-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
268+
env->permission_string(),
269269
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
270270
.Check();
271271
msg->Set(context,
272-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
272+
env->resource_string(),
273273
v8::String::NewFromUtf8(isolate,
274274
res.data(),
275275
v8::NewStringType::kNormal,
@@ -335,11 +335,11 @@ void Permission::Drop(Environment* env,
335335
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
336336
constchar* perm_str = PermissionToString(scope);
337337
msg->Set(context,
338-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
338+
env->permission_string(),
339339
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
340340
.Check();
341341
msg->Set(context,
342-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
342+
env->resource_string(),
343343
v8::String::NewFromUtf8(isolate,
344344
param.data(),
345345
v8::NewStringType::kNormal,

0 commit comments

Comments
 (0)