perf: replace String and Array indexOf method calls with includes method call (#55482)

This commit is contained in:
Sampo Kivistö
2023-08-25 21:27:55 +03:00
committed by GitHub
parent c3c5abb3a7
commit ec2bd4e252
46 changed files with 98 additions and 124 deletions

View File

@@ -104,7 +104,6 @@ import {
returnTrue,
ScriptTarget,
startsWith,
stringContains,
StringLiteral,
SyntaxKind,
sys,
@@ -1710,7 +1709,7 @@ export function parseListTypeOption(opt: CommandLineOptionOfListType, value = ""
if (startsWith(value, "-")) {
return undefined;
}
if (opt.type === "listOrElement" && !stringContains(value, ",")) {
if (opt.type === "listOrElement" && !value.includes(",")) {
return validateJsonOptionValue(opt, value, errors);
}
if (value === "") {
@@ -3078,7 +3077,7 @@ function parseConfig(
basePath = normalizeSlashes(basePath);
const resolvedPath = getNormalizedAbsolutePath(configFileName || "", basePath);
if (resolutionStack.indexOf(resolvedPath) >= 0) {
if (resolutionStack.includes(resolvedPath)) {
errors.push(createCompilerDiagnostic(Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, [...resolutionStack, resolvedPath].join(" -> ")));
return { raw: json || convertToObject(sourceFile!, errors) };
}