From 0eb6d984fb4d4c47c260b6b6447ad9877be9300c Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 17 Dec 2017 18:20:19 +0100 Subject: [PATCH] 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. PR-URL: https://github.com/nodejs/node/pull/17717 Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- lib/internal/http2/core.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index cce54ef377fe0c..72d43049645b2a 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -353,11 +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] = - Math.min(maxFramePayloadLen, - Math.max(frameLen, - fn(frameLen, - maxFramePayloadLen) | 0)); + paddingBuffer[PADDING_BUF_RETURN_VALUE] = fn(frameLen, maxFramePayloadLen); }; }