From fa0e8d7b3b953d16b3358204425bfd81d4171d18 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 d837b265c1ff4a..2882a3852504f3 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)