Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c1f1dbd

Browse filesBrowse files
addaleaxtargos
authored andcommitted
src: remove useless dereferencing in THROW_...
Our `THROW_...` helpers can handle strings or string views just fine, all this does is add an extra `strlen()` call that can and should be avoided. PR-URL: #60054 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent f490f91 commit c1f1dbd
Copy full SHA for c1f1dbd
Expand file treeCollapse file tree

14 files changed

+29
-30
lines changed
Open diff view settings
Collapse file

‎src/crypto/crypto_context.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_context.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
14601460
method = TLS_client_method();
14611461
} else {
14621462
THROW_ERR_TLS_INVALID_PROTOCOL_METHOD(
1463-
env, "Unknown method: %s", *sslmethod);
1463+
env, "Unknown method: %s", sslmethod);
14641464
return;
14651465
}
14661466
}
Collapse file

‎src/crypto/crypto_hash.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_hash.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ Maybe<void> HashTraits::AdditionalConfig(
502502
Utf8Value digest(env->isolate(), args[offset]);
503503
params->digest = ncrypto::getDigestByName(*digest);
504504
if (params->digest == nullptr) [[unlikely]] {
505-
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *digest);
505+
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", digest);
506506
return Nothing<void>();
507507
}
508508

Collapse file

‎src/crypto/crypto_hkdf.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_hkdf.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Maybe<void> HKDFTraits::AdditionalConfig(
5757
Utf8Value hash(env->isolate(), args[offset]);
5858
params->digest = Digest::FromName(*hash);
5959
if (!params->digest) [[unlikely]] {
60-
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *hash);
60+
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", hash);
6161
return Nothing<void>();
6262
}
6363

Collapse file

‎src/crypto/crypto_hmac.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_hmac.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Maybe<void> HmacTraits::AdditionalConfig(
197197
Utf8Value digest(env->isolate(), args[offset + 1]);
198198
params->digest = Digest::FromName(*digest);
199199
if (!params->digest) [[unlikely]] {
200-
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *digest);
200+
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", digest);
201201
return Nothing<void>();
202202
}
203203

Collapse file

‎src/crypto/crypto_pbkdf2.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_pbkdf2.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Maybe<void> PBKDF2Traits::AdditionalConfig(
103103
Utf8Value name(args.GetIsolate(), args[offset + 4]);
104104
params->digest = Digest::FromName(*name);
105105
if (!params->digest) [[unlikely]] {
106-
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *name);
106+
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", name);
107107
return Nothing<void>();
108108
}
109109

Collapse file

‎src/crypto/crypto_rsa.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_rsa.cc
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Maybe<void> RsaKeyGenTraits::AdditionalConfig(
143143
Utf8Value digest(env->isolate(), args[*offset]);
144144
params->params.md = Digest::FromName(*digest);
145145
if (!params->params.md) {
146-
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *digest);
146+
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", digest);
147147
return Nothing<void>();
148148
}
149149
}
@@ -153,8 +153,7 @@ Maybe<void> RsaKeyGenTraits::AdditionalConfig(
153153
Utf8Value digest(env->isolate(), args[*offset + 1]);
154154
params->params.mgf1_md = Digest::FromName(*digest);
155155
if (!params->params.mgf1_md) {
156-
THROW_ERR_CRYPTO_INVALID_DIGEST(
157-
env, "Invalid MGF1 digest: %s", *digest);
156+
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid MGF1 digest: %s", digest);
158157
return Nothing<void>();
159158
}
160159
}
@@ -279,7 +278,7 @@ Maybe<void> RSACipherTraits::AdditionalConfig(
279278
Utf8Value digest(env->isolate(), args[offset + 1]);
280279
params->digest = Digest::FromName(*digest);
281280
if (!params->digest) {
282-
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *digest);
281+
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", digest);
283282
return Nothing<void>();
284283
}
285284

Collapse file

‎src/crypto/crypto_sig.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_sig.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ Maybe<void> SignTraits::AdditionalConfig(
627627
Utf8Value digest(env->isolate(), args[offset + 6]);
628628
params->digest = Digest::FromName(*digest);
629629
if (!params->digest) [[unlikely]] {
630-
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *digest);
630+
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", digest);
631631
return Nothing<void>();
632632
}
633633
}
Collapse file

‎src/node_binding.cc‎

Copy file name to clipboardExpand all lines: src/node_binding.cc
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,9 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
487487
dlib->Close();
488488
#ifdef _WIN32
489489
// Windows needs to add the filename into the error message
490-
errmsg += *filename;
490+
errmsg += filename.ToStringView();
491491
#endif // _WIN32
492-
THROW_ERR_DLOPEN_FAILED(env, "%s", errmsg.c_str());
492+
THROW_ERR_DLOPEN_FAILED(env, "%s", errmsg);
493493
return false;
494494
}
495495

@@ -520,7 +520,7 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
520520
if (mp == nullptr || mp->nm_context_register_func == nullptr) {
521521
dlib->Close();
522522
THROW_ERR_DLOPEN_FAILED(
523-
env, "Module did not self-register: '%s'.", *filename);
523+
env, "Module did not self-register: '%s'.", filename);
524524
return false;
525525
}
526526
}
@@ -649,7 +649,7 @@ void GetInternalBinding(const FunctionCallbackInfo<Value>& args) {
649649
exports = InitInternalBinding(realm, mod);
650650
realm->internal_bindings.insert(mod);
651651
} else {
652-
return THROW_ERR_INVALID_MODULE(isolate, "No such binding: %s", *module_v);
652+
return THROW_ERR_INVALID_MODULE(isolate, "No such binding: %s", module_v);
653653
}
654654

655655
args.GetReturnValue().Set(exports);
@@ -680,7 +680,7 @@ void GetLinkedBinding(const FunctionCallbackInfo<Value>& args) {
680680

681681
if (mod == nullptr) {
682682
return THROW_ERR_INVALID_MODULE(
683-
env, "No such binding was linked: %s", *module_name_v);
683+
env, "No such binding was linked: %s", module_name_v);
684684
}
685685

686686
Local<Object> module = Object::New(env->isolate());
Collapse file

‎src/node_process_methods.cc‎

Copy file name to clipboardExpand all lines: src/node_process_methods.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ static void LoadEnvFile(const v8::FunctionCallbackInfo<v8::Value>& args) {
613613
}
614614
case dotenv.ParseResult::InvalidContent: {
615615
THROW_ERR_INVALID_ARG_TYPE(
616-
env, "Contents of '%s' should be a valid string.", path.c_str());
616+
env, "Contents of '%s' should be a valid string.", path);
617617
break;
618618
}
619619
case dotenv.ParseResult::FileError: {
Collapse file

‎src/node_report.cc‎

Copy file name to clipboardExpand all lines: src/node_report.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static void PrintJavaScriptStack(JSONWriter* writer,
501501
const int column = frame->GetColumn();
502502

503503
std::string stack_line = SPrintF(
504-
"at %s (%s:%d:%d)", *function_name, *script_name, line_number, column);
504+
"at %s (%s:%d:%d)", function_name, script_name, line_number, column);
505505
writer->json_element(stack_line);
506506
}
507507
writer->json_arrayend();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.