Adjust logic

This commit is contained in:
sanex3339
2026-03-22 14:22:43 +07:00
parent a33325d675
commit 1d17109137
2 changed files with 16 additions and 5 deletions
@@ -14,7 +14,7 @@ export abstract class AbstractIdentifierNamesGenerator implements IIdentifierNam
/**
* @type {number}
*/
private static readonly maxGenerationAttempts: number = 1000;
private static readonly maxGenerationAttempts: number = 10000;
/**
* @type {IOptions}
@@ -282,14 +282,25 @@ export class MangledIdentifierNamesGenerator extends AbstractIdentifierNamesGene
};
let identifierName: string = previousMangledName;
let isValidIdentifierName: boolean;
let attempts: number = 0;
let isValidIdentifierName: boolean = false;
let reservedNameAttempts: number = 0;
do {
this.checkGenerationAttempts(attempts);
identifierName = generateNewMangledName(identifierName);
if (
this.preservedNamesSet.has(identifierName) ||
MangledIdentifierNamesGenerator.reservedNamesSet.has(identifierName)
) {
continue;
}
isValidIdentifierName = validationFunction?.(identifierName) ?? this.isValidIdentifierName(identifierName);
attempts++;
if (!isValidIdentifierName) {
this.checkGenerationAttempts(reservedNameAttempts);
reservedNameAttempts++;
}
} while (!isValidIdentifierName);
return identifierName;