New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http: use v8::Array::New() with a prebuilt vector #46447
base: main
Are you sure you want to change the base?
Conversation
Avoid using v8::Array::Set() which results in JS execution and is thus slow. Prebuild the vector in C++ land and build the JS array directly with that vector whereever possible.
|
Review requested:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
| ConnectionsList* list; | ||
|
|
||
| ASSIGN_OR_RETURN_UNWRAP(&list, args.Holder()); | ||
|
|
||
| uint32_t i = 0; | ||
| std::vector<Local<Value>> result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| std::vector<Local<Value>> result; | |
| std::vector<Local<Value>> result; | |
| result.reserve(list->all_connections_.size()); |
| ConnectionsList* list; | ||
|
|
||
| ASSIGN_OR_RETURN_UNWRAP(&list, args.Holder()); | ||
|
|
||
| uint32_t i = 0; | ||
| std::vector<Local<Value>> result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| std::vector<Local<Value>> result; | |
| std::vector<Local<Value>> result; | |
| result.reserve(list->all_connections_.size()); |
| ConnectionsList* list; | ||
|
|
||
| ASSIGN_OR_RETURN_UNWRAP(&list, args.Holder()); | ||
|
|
||
| uint32_t i = 0; | ||
| std::vector<Local<Value>> result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| std::vector<Local<Value>> result; | |
| std::vector<Local<Value>> result; | |
| result.reserve(list->all_connections_.size()); |
| auto iter = list->active_connections_.begin(); | ||
| auto end = list->active_connections_.end(); | ||
|
|
||
| std::vector<Local<Value>> result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| std::vector<Local<Value>> result; | |
| std::vector<Local<Value>> result; | |
| result.reserve(list->all_connections_.size()); |


Avoid using v8::Array::Set() which results in JS execution and is thus slow. Prebuild the vector in C++ land and build the JS array directly with that vector whereever possible.