From 4a6385743df50fad89635cdb90382b74245deee9 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 30 Jun 2026 12:54:53 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Optimize=20architectureFileBaseName?= =?UTF-8?q?=20to=20avoid=20array=20allocations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: julesklord <801266+julesklord@users.noreply.github.com> --- src/lib/parser.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/parser.js b/src/lib/parser.js index 89e616d..619fef8 100644 --- a/src/lib/parser.js +++ b/src/lib/parser.js @@ -2993,8 +2993,16 @@ function stripArchitectureExt(path){ } function architectureFileBaseName(path){ - var base=stripArchitectureExt(path).split('/').pop()||'Block'; - return base==='index'?(stripArchitectureExt(path).split('/').slice(-2,-1)[0]||base):base; + var str = stripArchitectureExt(path); + var idx = str.lastIndexOf('/'); + var base = idx === -1 ? str : str.substring(idx + 1); + if (!base) base = 'Block'; + if (base === 'index' && idx > 0) { + var prevIdx = str.lastIndexOf('/', idx - 1); + var dirName = prevIdx === -1 ? str.substring(0, idx) : str.substring(prevIdx + 1, idx); + return dirName || base; + } + return base; } function normalizeArchitectureRoute(route){