From e6e6c916b5cc239127eef121e5122d877f830a5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sat, 6 Jul 2024 20:27:59 +0200 Subject: [PATCH] crypto: avoid std::function Using a template type lets the compiler choose an appropriate type that likely is more efficient than std::function since the lambda expressions at the call sites do not capture any values from surrounding scopes. PR-URL: https://github.com/nodejs/node/pull/53683 Reviewed-By: Joyee Cheung Reviewed-By: Filip Skokan Reviewed-By: Yagiz Nizipli Reviewed-By: James M Snell Reviewed-By: Mohammed Keyvanzadeh --- src/crypto/crypto_keys.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/crypto/crypto_keys.cc b/src/crypto/crypto_keys.cc index abde5b79dabcac..db03387d42c816 100644 --- a/src/crypto/crypto_keys.cc +++ b/src/crypto/crypto_keys.cc @@ -75,12 +75,11 @@ void GetKeyFormatAndTypeFromJs( *offset += 2; } -ParseKeyResult TryParsePublicKey( - EVPKeyPointer* pkey, - const BIOPointer& bp, - const char* name, - // NOLINTNEXTLINE(runtime/int) - const std::function& parse) { +template +ParseKeyResult TryParsePublicKey(EVPKeyPointer* pkey, + const BIOPointer& bp, + const char* name, + F&& parse) { unsigned char* der_data; long der_len; // NOLINT(runtime/int)