Skip to content

Commit

Permalink
AbstractCompilerMojo: Replace StringBuilder with String.join()
Browse files Browse the repository at this point in the history
Initialize patchModules = new LinkedHashSet with capacity.

Signed-off-by: Sergey Ponomarev <[email protected]>
  • Loading branch information
turbanoff authored and slachiewicz committed Oct 13, 2024
1 parent c805b8f commit e879516
Showing 1 changed file with 5 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1013,15 +1013,9 @@ public void execute() {
}

String[] cl = compiler.createCommandLine(compilerConfiguration);
if (cl != null && cl.length > 0) {
StringBuilder sb = new StringBuilder();
sb.append(cl[0]);
for (int i = 1; i < cl.length; i++) {
sb.append(" ");
sb.append(cl[i]);
}
if (cl != null && cl.length > 0 && getLog().isDebugEnabled()) {
getLog().debug("Command line options:");
getLog().debug(sb.toString());
getLog().debug(String.join(" ", cl));
}
} catch (CompilerException ce) {
getLog().debug("Compilation error", ce);
Expand Down Expand Up @@ -1058,13 +1052,12 @@ public void execute() {

String[] values = value.split("=");

StringBuilder patchModule = new StringBuilder(values[0]);
patchModule.append('=');
String patchModule = values[0] + "=";

Set<String> patchModules = new LinkedHashSet<>();
Set<Path> sourceRoots = new HashSet<>(getCompileSourceRoots());

String[] files = values[1].split(PS);
Set<String> patchModules = new LinkedHashSet<>(files.length, 1);

for (String file : files) {
Path filePath = Paths.get(file);
Expand All @@ -1090,19 +1083,9 @@ public void execute() {
}
}

StringBuilder sb = new StringBuilder();

if (!patchModules.isEmpty()) {
for (String mod : patchModules) {
if (sb.length() > 0) {
sb.append(", ");
}
// use 'invalid' separator to ensure values are transformed
sb.append(mod);
}

jpmsLines.add("--patch-module");
jpmsLines.add(patchModule + sb.toString());
jpmsLines.add(patchModule + String.join(", ", patchModules));
}
}
}
Expand Down

0 comments on commit e879516

Please sign in to comment.