From 195d404bc2190887ebd14140aea0b15b851dbef1 Mon Sep 17 00:00:00 2001 From: Will Harney <62956339+wjhsf@users.noreply.github.com> Date: Wed, 27 Nov 2024 12:13:22 -0500 Subject: [PATCH] chore: remove unused helper (#4970) We've moved to a pattern of using block statements for more descriptive variable names. The `getUniqueVar` helper is no longer used anywhere. --- .../src/compile-template/context.ts | 20 ------------------- .../src/compile-template/types.ts | 1 - 2 files changed, 21 deletions(-) diff --git a/packages/@lwc/ssr-compiler/src/compile-template/context.ts b/packages/@lwc/ssr-compiler/src/compile-template/context.ts index efa20bb664..0d58b5259f 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/context.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/context.ts @@ -9,22 +9,6 @@ import { bImportDeclaration } from '../estree/builders'; import type { ImportDeclaration as EsImportDeclaration } from 'estree'; import type { TemplateOpts, TransformerContext } from './types'; -const identifierChars = 'abcdefghijklmnopqrstuvwxyz'; - -function genId(n: number, prevChars = ''): string { - const remaining = Math.floor(n / identifierChars.length); - const result = identifierChars.charAt(n % identifierChars.length) + prevChars; - - return remaining <= 0 ? result : genId(remaining - 1, result); -} - -function* genIds() { - let counter = 0; - while (true) { - yield genId(counter++); - } -} - export function createNewContext(templateOptions: TemplateOpts): { getImports: () => EsImportDeclaration[]; cxt: TransformerContext; @@ -85,16 +69,12 @@ export function createNewContext(templateOptions: TemplateOpts): { return false; }; - const uniqueVarGenerator = genIds(); - const getUniqueVar = () => uniqueVarGenerator.next().value!; - return { getImports, cxt: { pushLocalVars, popLocalVars, isLocalVar, - getUniqueVar, templateOptions, import: _import, }, diff --git a/packages/@lwc/ssr-compiler/src/compile-template/types.ts b/packages/@lwc/ssr-compiler/src/compile-template/types.ts index c80473722e..4f344d58e0 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/types.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/types.ts @@ -17,7 +17,6 @@ export interface TransformerContext { pushLocalVars: (vars: string[]) => void; popLocalVars: () => void; isLocalVar: (varName: string | null | undefined) => boolean; - getUniqueVar: () => string; templateOptions: TemplateOpts; prevSibling?: IrNode; nextSibling?: IrNode;