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 <joyeec9h3@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
  • Loading branch information
tniessen authored and aduh95 committed Jul 16, 2024
1 parent 81767f6 commit 5697938
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 5697938

Please sign in to comment.