Skip to content

Commit

Permalink
chore: remove unused helper (#4970)
Browse files Browse the repository at this point in the history
We've moved to a pattern of using block statements for more descriptive variable names. The `getUniqueVar` helper is no longer used anywhere.
  • Loading branch information
wjhsf authored Nov 27, 2024
1 parent 2b42245 commit 195d404
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
20 changes: 0 additions & 20 deletions packages/@lwc/ssr-compiler/src/compile-template/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
},
Expand Down
1 change: 0 additions & 1 deletion packages/@lwc/ssr-compiler/src/compile-template/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 195d404

Please sign in to comment.