Skip to content

Commit

Permalink
crypto: avoid std::function
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tniessen authored and marco-ippolito committed Aug 19, 2024
1 parent ef5dabd commit fa0e8d7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/crypto/crypto_keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,11 @@ void GetKeyFormatAndTypeFromJs(
*offset += 2;
}

ParseKeyResult TryParsePublicKey(
EVPKeyPointer* pkey,
const BIOPointer& bp,
const char* name,
// NOLINTNEXTLINE(runtime/int)
const std::function<EVP_PKEY*(const unsigned char** p, long l)>& parse) {
template <typename F>
ParseKeyResult TryParsePublicKey(EVPKeyPointer* pkey,
const BIOPointer& bp,
const char* name,
F&& parse) {
unsigned char* der_data;
long der_len; // NOLINT(runtime/int)

Expand Down

0 comments on commit fa0e8d7

Please sign in to comment.