Skip to content

Commit 5b4c859

Browse files
committed
Trivial refactor: use replace instead
1 parent 75d9302 commit 5b4c859

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyEngine.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ public Object execute(String statement) throws Exception {
409409
Object out = null;
410410
if (statement.matches("import\\s+module\\s+([^;\\s]+)\\s*(;)?")) {
411411
String[] p = statement.split("\\s+");
412-
String moduleName = p[2].replaceAll(";", "");
412+
String moduleName = p[2].replace(";", "");
413413
executeStatement(shell, snippets, EnumSet.of(SnippetType.IMPORT), statement);
414414
imports.put("module " + moduleName, addSnippet(SnippetType.IMPORT, statement));
415415
// Populate the completion cache with exported packages from the module
@@ -430,14 +430,14 @@ public Object execute(String statement) throws Exception {
430430
}
431431
String classname = null;
432432
if (classIdx < p.length) {
433-
classname = p[classIdx].replaceAll(";", "");
433+
classname = p[classIdx].replace(";", "");
434434
addToNameClass(classname);
435435
if (isStatic) {
436436
classname = "static " + classname;
437437
}
438438
// check for alias
439439
if (p.length > 3) {
440-
classname = p[p.length - 1].replaceAll(";", "");
440+
classname = p[p.length - 1].replace(";", "");
441441
}
442442
}
443443
executeStatement(shell, snippets, EnumSet.of(SnippetType.IMPORT), statement);

subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/JrtJavaBasePackages.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attr) {
7777
try {
7878
String name = file.toString().substring(18);
7979
if (name.endsWith(".class") && (nestedClasses || !name.contains("$"))) {
80-
String className = name.substring(0, name.length() - 6).replaceAll("/", ".");
80+
String className = name.substring(0, name.length() - 6).replace('/', '.');
8181
if (Character.isUpperCase(className.charAt(packageName.length() + 1))) {
8282
classes.add(Class.forName(className));
8383
} else {

0 commit comments

Comments
 (0)