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

@@ -71,7 +71,7 @@ async function checkSourceFiles() {
let count = 0;
console.log("== List of errors not used in source ==");
for (const errName of errorNames) {
if (allSrc.indexOf(errName) < 0) {
if (!allSrc.includes(errName)) {
console.log(errName);
count++;
}

View File

@@ -157,7 +157,7 @@ module.exports = createRule({
}
}
const hasNewLine = sourceCodeText.slice(commentRangeEnd, argRangeStart).indexOf("\n") >= 0;
const hasNewLine = sourceCodeText.slice(commentRangeEnd, argRangeStart).includes("\n");
if (argRangeStart !== commentRangeEnd + 1 && !hasNewLine) {
// TODO(jakebailey): range should be whitespace
context.report({

View File

@@ -88,7 +88,7 @@ async function main() {
const mergeTree = runSequence([
["git", ["merge-tree", mergeBase.trim(), branch, "experimental"]],
]);
if (mergeTree.indexOf(`===${"="}===`) >= 0) { // 7 equals is the center of the merge conflict marker
if (mergeTree.includes(`===${"="}===`)) { // 7 equals is the center of the merge conflict marker
throw new Error(`Merge conflict detected involving PR ${branch} with other experiment`);
}
// Merge (always producing a merge commit)