From a38941c5e7227795f4d3d6b0f5ada3d23f041cd5 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 d047b394ba6b45..7d8ec2e772002e 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -413,11 +413,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); }; }