From 48a12ac225d7a1ab65f48b811eae20654339b15b Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 25 May 2026 15:03:58 +0200 Subject: [PATCH] Avoid a temporary variable and return results directly in a couple of functions --- src/core/font_renderer.js | 9 +++------ web/ui_utils.js | 7 ++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/core/font_renderer.js b/src/core/font_renderer.js index 0c0fcdd8e..10cbbac0c 100644 --- a/src/core/font_renderer.js +++ b/src/core/font_renderer.js @@ -37,13 +37,10 @@ function getFloat214(view, offset) { function getSubroutineBias(subrs) { const numSubrs = subrs.length; - let bias = 32768; - if (numSubrs < 1240) { - bias = 107; - } else if (numSubrs < 33900) { - bias = 1131; + if (numSubrs >= 33900) { + return 32768; } - return bias; + return numSubrs < 1240 ? 107 : 1131; } function parseCmap(data, start, end) { diff --git a/web/ui_utils.js b/web/ui_utils.js index e72400ac9..0dd10b39c 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -266,14 +266,11 @@ function approximateFraction(x) { b = q; } } - let result; // Select closest of the neighbours to x. if (x_ - a / b < c / d - x_) { - result = x_ === x ? [a, b] : [b, a]; - } else { - result = x_ === x ? [c, d] : [d, c]; + return x_ === x ? [a, b] : [b, a]; } - return result; + return x_ === x ? [c, d] : [d, c]; } /**