Skip to content

Commit fa0e8d7

Browse files
tniessenmarco-ippolito
authored andcommitted
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: #53683 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
1 parent ef5dabd commit fa0e8d7

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/crypto/crypto_keys.cc

+5-6
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,11 @@ void GetKeyFormatAndTypeFromJs(
7575
*offset += 2;
7676
}
7777

78-
ParseKeyResult TryParsePublicKey(
79-
EVPKeyPointer* pkey,
80-
const BIOPointer& bp,
81-
const char* name,
82-
// NOLINTNEXTLINE(runtime/int)
83-
const std::function<EVP_PKEY*(const unsigned char** p, long l)>& parse) {
78+
template <typename F>
79+
ParseKeyResult TryParsePublicKey(EVPKeyPointer* pkey,
80+
const BIOPointer& bp,
81+
const char* name,
82+
F&& parse) {
8483
unsigned char* der_data;
8584
long der_len; // NOLINT(runtime/int)
8685

0 commit comments

Comments
 (0)