mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
src: improve node_crypto.cc memory allocation
This avoids heap allocations in common cases PR-URL: https://github.com/nodejs/node/pull/30751 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
efd6775a50
commit
c9d4949565
@ -2697,11 +2697,11 @@ void SSLWrap<Base>::GetSharedSigalgs(const FunctionCallbackInfo<Value>& args) {
|
||||
Base* w;
|
||||
ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder());
|
||||
Environment* env = w->ssl_env();
|
||||
std::vector<Local<Value>> ret_arr;
|
||||
|
||||
SSL* ssl = w->ssl_.get();
|
||||
int nsig = SSL_get_shared_sigalgs(ssl, 0, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr);
|
||||
MaybeStackBuffer<Local<Value>, 16> ret_arr(nsig);
|
||||
|
||||
for (int i = 0; i < nsig; i++) {
|
||||
int hash_nid;
|
||||
@ -2765,12 +2765,11 @@ void SSLWrap<Base>::GetSharedSigalgs(const FunctionCallbackInfo<Value>& args) {
|
||||
} else {
|
||||
sig_with_md += "UNDEF";
|
||||
}
|
||||
|
||||
ret_arr.push_back(OneByteString(env->isolate(), sig_with_md.c_str()));
|
||||
ret_arr[i] = OneByteString(env->isolate(), sig_with_md.c_str());
|
||||
}
|
||||
|
||||
args.GetReturnValue().Set(
|
||||
Array::New(env->isolate(), ret_arr.data(), ret_arr.size()));
|
||||
Array::New(env->isolate(), ret_arr.out(), ret_arr.length()));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user