Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 08ac9b6

Browse filesBrowse files
piyukore06targos
authored andcommitted
src: improve node_crypto.cc memory allocation
This avoids heap allocations in common cases PR-URL: #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>
1 parent cf19ec0 commit 08ac9b6
Copy full SHA for 08ac9b6

File tree

Expand file treeCollapse file tree

1 file changed

+3
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-4
lines changed
Open diff view settings
Collapse file

‎src/node_crypto.cc‎

Copy file name to clipboardExpand all lines: src/node_crypto.cc
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2697,11 +2697,11 @@ void SSLWrap<Base>::GetSharedSigalgs(const FunctionCallbackInfo<Value>& args) {
26972697
Base* w;
26982698
ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder());
26992699
Environment* env = w->ssl_env();
2700-
std::vector<Local<Value>> ret_arr;
27012700

27022701
SSL* ssl = w->ssl_.get();
27032702
int nsig = SSL_get_shared_sigalgs(ssl, 0, nullptr, nullptr, nullptr, nullptr,
27042703
nullptr);
2704+
MaybeStackBuffer<Local<Value>, 16> ret_arr(nsig);
27052705

27062706
for (int i = 0; i < nsig; i++) {
27072707
int hash_nid;
@@ -2765,12 +2765,11 @@ void SSLWrap<Base>::GetSharedSigalgs(const FunctionCallbackInfo<Value>& args) {
27652765
} else {
27662766
sig_with_md += "UNDEF";
27672767
}
2768-
2769-
ret_arr.push_back(OneByteString(env->isolate(), sig_with_md.c_str()));
2768+
ret_arr[i] = OneByteString(env->isolate(), sig_with_md.c_str());
27702769
}
27712770

27722771
args.GetReturnValue().Set(
2773-
Array::New(env->isolate(), ret_arr.data(), ret_arr.size()));
2772+
Array::New(env->isolate(), ret_arr.out(), ret_arr.length()));
27742773
}
27752774

27762775

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.