From 01b4c24171d65c92bc0ff7bf47c2260c617f5400 Mon Sep 17 00:00:00 2001 From: Jukka Kurkela Date: Thu, 7 Feb 2019 09:31:52 +0200 Subject: [PATCH] cache repeated Math.min --- src/elements/element.rectangle.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/elements/element.rectangle.js b/src/elements/element.rectangle.js index c2dfc87fab8..27b90883787 100644 --- a/src/elements/element.rectangle.js +++ b/src/elements/element.rectangle.js @@ -104,11 +104,13 @@ module.exports = Element.extend({ right: Math.min(borderWidth.right || 0, maxWidth) }; } else { + maxWidth = Math.min(borderWidth, maxWidth); + maxHeight = Math.min(borderWidth, maxHeight); borderWidth = { - bottom: borderSkipped === 'bottom' ? 0 : Math.min(borderWidth, maxHeight), - left: borderSkipped === 'left' ? 0 : Math.min(borderWidth, maxWidth), - top: borderSkipped === 'top' ? 0 : Math.min(borderWidth, maxHeight), - right: borderSkipped === 'right' ? 0 : Math.min(borderWidth, maxWidth) + bottom: borderSkipped === 'bottom' ? 0 : maxHeight, + left: borderSkipped === 'left' ? 0 : maxWidth, + top: borderSkipped === 'top' ? 0 : maxHeight, + right: borderSkipped === 'right' ? 0 : maxWidth }; }