From e099bd9790fa3425a3be6e9469e06ab07662e561 Mon Sep 17 00:00:00 2001 From: Alex Kanunnikov Date: Wed, 6 Dec 2023 01:51:15 +0300 Subject: [PATCH] [perf] replace Math.max usage to reduce and pure compare --- packages/@glimmer/validator/lib/validators.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/@glimmer/validator/lib/validators.ts b/packages/@glimmer/validator/lib/validators.ts index da94e38069..9342cae669 100644 --- a/packages/@glimmer/validator/lib/validators.ts +++ b/packages/@glimmer/validator/lib/validators.ts @@ -137,19 +137,19 @@ class MonomorphicTagImpl { if (subtag !== null) { if (Array.isArray(subtag)) { - for (const tag of subtag) { - let value = tag[COMPUTE](); - revision = Math.max(value, revision); - } + revision = subtag.reduce((prev, currentTag: Tag) => { + let current = currentTag[COMPUTE](); + return current > prev ? current : prev; + }, revision); } else { let subtagValue = subtag[COMPUTE](); if (subtagValue === this.subtagBufferCache) { - revision = Math.max(revision, this.lastValue); + revision = revision > this.lastValue ? revision : this.lastValue; } else { // Clear the temporary buffer cache this.subtagBufferCache = null; - revision = Math.max(revision, subtagValue); + revision = revision > subtagValue ? revision : subtagValue; } } }