From c0a17618c78b2f9b7a7e393ee58dfe20c6b3ea79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Tue, 2 Jul 2024 08:33:12 +0000 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. --- 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)