Skip to content

Optimize V8 return values using POD Set overloads - #1341

Merged
uNetworkingAB merged 4 commits into
masterfrom
copilot/find-and-update-set-methods
Oct 1, 2026
Merged

uNetworkingAB merged 4 commits into
masterfrom
copilot/find-and-update-set-methods

Conversation

Copilot AI commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

The V8 bindings were using heavy heap-allocated wrapper objects (such as v8::Boolean, v8::Integer, and v8::Number) when returning primitive values to JavaScript. This pull request replaces these wrapped returns with direct V8 POD (Plain Old Data) Set overloads, improving execution performance and reducing heap allocation overhead.

Refactored Bindings

  • WebSocket Bindings (src/WebSocketWrapper.h)

    • Replaced Boolean::New(isolate, success) with direct boolean returns.
    • Replaced Integer::NewFromUnsigned(isolate, port) with direct uint32_t returns for port, buffered amount, and send status.
  • HTTP Response Bindings (src/HttpResponseWrapper.h)

    • Replaced Boolean::New with direct boolean returns in write responses.
    • Avoided Integer::NewFromUnsigned and Number::New wrapper objects for port and write offsets.
  • App Bindings (src/AppWrapper.h)

    • Streamlined subscriber counts, app descriptor pointers, and publishing success checks to return primitive types directly.
  • Addon Utilities (src/addon.cpp)

    • Updated socket port and temporary KV store value returns to use plain integers.

Code Pattern Example

Before:

bool success = ws->subscribe(topic.getString());
args.GetReturnValue().Set(Boolean::New(isolate, success));

After:

bool success = ws->subscribe(topic.getString());
args.GetReturnValue().Set(success);

Copilot AI and others added 4 commits September 30, 2026 23:00
Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com>
Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com>
Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com>
Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com>
@uNetworkingAB
uNetworkingAB marked this pull request as ready for review October 1, 2026 00:21
@uNetworkingAB
uNetworkingAB merged commit 4d51bb4 into master Oct 1, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants