Skip to content

Commit 27bfced

Browse files
committed
Avoid multiple calls to .ToStringView()
1 parent 01fe3df commit 27bfced

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/crypto/crypto_argon2.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Maybe<void> Argon2Traits::AdditionalConfig(
6060
ArrayBufferOrViewContents<char> salt(args[offset + 1]);
6161
ArrayBufferOrViewContents<char> secret(args[offset + 6]);
6262
ArrayBufferOrViewContents<char> ad(args[offset + 7]);
63-
Utf8Value type_(env->isolate(), args[offset + 8]);
63+
Utf8Value algorithm(env->isolate(), args[offset + 8]);
6464

6565
if (!pass.CheckSizeInt32()) [[unlikely]] {
6666
THROW_ERR_OUT_OF_RANGE(env, "pass is too large");
@@ -88,11 +88,11 @@ Maybe<void> Argon2Traits::AdditionalConfig(
8888
config->secret = isAsync ? secret.ToCopy() : secret.ToByteSource();
8989
config->ad = isAsync ? ad.ToCopy() : ad.ToByteSource();
9090

91-
if (type_.ToStringView() == "argon2i") {
91+
if (algorithm == "argon2i") {
9292
config->type = ncrypto::Argon2Type::ARGON2I;
93-
} else if (type_.ToStringView() == "argon2d") {
93+
} else if (algorithm == "argon2d") {
9494
config->type = ncrypto::Argon2Type::ARGON2D;
95-
} else if (type_.ToStringView() == "argon2id") {
95+
} else if (algorithm == "argon2id") {
9696
config->type = ncrypto::Argon2Type::ARGON2ID;
9797
} else {
9898
THROW_ERR_CRYPTO_INVALID_ARGON2_PARAMS(env);

0 commit comments

Comments
 (0)