From 5ee32f7b2bf8c83584df6168c4ae0ab5a5221d41 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 17 Dec 2017 18:20:19 +0100 Subject: [PATCH 1/2] http2: simplify onSelectPadding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `OnCallbackPadding` on the native side already clamps the return value into the right range, so there’s not need to also do that on the JS side. Also, use `>>> 0` instead of `| 0` to get an uint32, since the communication with C++ land happens through an Uint32Array. --- lib/internal/http2/core.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 78446d2fb6e112..9aae4369344469 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -354,10 +354,7 @@ function onSelectPadding(fn) { const frameLen = paddingBuffer[PADDING_BUF_FRAME_LENGTH]; const maxFramePayloadLen = paddingBuffer[PADDING_BUF_MAX_PAYLOAD_LENGTH]; paddingBuffer[PADDING_BUF_RETURN_VALUE] = - Math.min(maxFramePayloadLen, - Math.max(frameLen, - fn(frameLen, - maxFramePayloadLen) | 0)); + fn(frameLen, maxFramePayloadLen) >>> 0; }; } From 9e52c53063d6c60345d7cdc61c3c31820e6258db Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 18 Dec 2017 16:21:43 +0100 Subject: [PATCH 2/2] [squash] remove uint32 cast --- lib/internal/http2/core.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 9aae4369344469..7250b511753fb4 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -353,8 +353,7 @@ function onSelectPadding(fn) { return function getPadding() { const frameLen = paddingBuffer[PADDING_BUF_FRAME_LENGTH]; const maxFramePayloadLen = paddingBuffer[PADDING_BUF_MAX_PAYLOAD_LENGTH]; - paddingBuffer[PADDING_BUF_RETURN_VALUE] = - fn(frameLen, maxFramePayloadLen) >>> 0; + paddingBuffer[PADDING_BUF_RETURN_VALUE] = fn(frameLen, maxFramePayloadLen); }; }