Use String.replace() instead of replaceAll() (#13047)

This commit is contained in:
Dmitry Cherniachenko 2024-01-30 00:13:43 +01:00 committed by GitHub
parent e3a6a4bd8f
commit 0c2802f37a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 10 additions and 11 deletions

View File

@ -478,14 +478,14 @@ public class TestHTMLStripCharFilter extends BaseTokenStreamTestCase {
// ">"
=
TestUtil.randomHtmlishString(random(), maxNumElems)
.replaceAll(">", " ")
.replace('>', ' ')
.replaceFirst("^--", "__");
String closedAngleBangNonCDATA = "<!" + randomHtmlishString1 + "-[CDATA[&]]>";
// Don't create a comment (disallow "<!--") and don't include a closing ">"
String randomHtmlishString2 =
TestUtil.randomHtmlishString(random(), maxNumElems)
.replaceAll(">", " ")
.replace('>', ' ')
.replaceFirst("^--", "__");
String unclosedAngleBangNonCDATA = "<!" + randomHtmlishString2 + "-[CDATA[";

View File

@ -64,7 +64,7 @@ public class RepAllTask extends ReportTask {
String line = taskReportLine(longestOp, stat);
reported++;
if (taskStats.size() > 2 && reported % 2 == 0) {
line = line.replaceAll(" ", " - ");
line = line.replace(" ", " - ");
}
sb.append(line);
}

View File

@ -69,7 +69,7 @@ public class RepSelectByPrefTask extends RepSumByPrefTask {
first = false;
String line = taskReportLine(longestOp, stat);
if (taskStats.size() > 2 && reported % 2 == 0) {
line = line.replaceAll(" ", " - ");
line = line.replace(" ", " - ");
}
sb.append(line);
}

View File

@ -140,7 +140,7 @@ public abstract class ReportTask extends PerfTask {
String line = taskReportLine(longetOp, stat);
lineNum++;
if (partOfTasks.size() > 2 && lineNum % 2 == 0) {
line = line.replaceAll(" ", " - ");
line = line.replace(" ", " - ");
}
sb.append(line);
int[] byTime = stat.getCountsByTime();

View File

@ -961,12 +961,11 @@ public class TestPerfTasksLogic extends BenchmarkTestCase {
}
private String[] getAnalyzerFactoryConfig(String name, String params) {
final String singleQuoteEscapedName = name.replaceAll("'", "\\\\'");
final String singleQuoteEscapedName = name.replace("'", "\\'");
String[] algLines = {
"content.source=org.apache.lucene.benchmark.byTask.feeds.LineDocSource",
"docs.file=" + getReuters20LinesFile(),
"work.dir="
+ getWorkDir().toAbsolutePath().toString().replaceAll("\\\\", "/"), // Fix Windows path
"work.dir=" + getWorkDir().toAbsolutePath().toString().replace('\\', '/'), // Fix Windows path
"content.source.forever=false",
"directory=ByteBuffersDirectory",
"AnalyzerFactory(name:'" + singleQuoteEscapedName + "', " + params + ")",

View File

@ -142,11 +142,11 @@ public class TestRegExp extends LuceneTestCase {
break;
case 3:
// Star-replace all ab sequences.
result.append(replacementPart.replaceAll("ab", ".*"));
result.append(replacementPart.replace("ab", ".*"));
break;
case 4:
// .-replace all b chars
result.append(replacementPart.replaceAll("b", "."));
result.append(replacementPart.replace("b", "."));
break;
case 5:
// length-limited stars {1,2}
@ -165,7 +165,7 @@ public class TestRegExp extends LuceneTestCase {
break;
case 8:
// NOT a character - replace all b's with "not a"
result.append(replacementPart.replaceAll("b", "[^a]"));
result.append(replacementPart.replace("b", "[^a]"));
break;
case 9:
// Make whole part repeatable 1 or more times