Skip to content

Commit

Permalink
improve RegistrationMacOsX performance #2245
Browse files Browse the repository at this point in the history
Pattern matching with String.split("-{80}\n") is quiet expensive
especially if the string contains more then 80 dashes in a row.

#2245
  • Loading branch information
EcljpseB0T authored and jukzi committed Sep 13, 2024
1 parent 52470ac commit 2dcc3f0
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class RegistrationMacOsX implements IOperatingSystemRegistration {
private IFileProvider fileProvider;
private IProcessExecutor processExecutor;

private String lsRegisterOutput = null;
private String[] lsRegisterOutput = null;

public RegistrationMacOsX() {
this(new FileProvider(), new ProcessExecutor());
Expand Down Expand Up @@ -75,17 +75,15 @@ public List<ISchemeInformation> getSchemesInformation(Collection<IScheme> scheme
return returnList;
}

private String getLsRegisterOutput() throws Exception {
private String[] getLsRegisterOutput() throws Exception {
if (this.lsRegisterOutput != null) {
return this.lsRegisterOutput;
}
this.lsRegisterOutput = processExecutor.execute(LSREGISTER, DUMP);
this.lsRegisterOutput = processExecutor.execute(LSREGISTER, DUMP).split("-".repeat(80) + "\n"); //$NON-NLS-1$//$NON-NLS-2$
return this.lsRegisterOutput;
}

private String determineHandlerLocation(String lsRegisterDump, String scheme) {

String[] lsRegisterEntries = lsRegisterDump.split("-{80}\n"); //$NON-NLS-1$
private String determineHandlerLocation(String[] lsRegisterEntries, String scheme) {
String keyOfFirstLine;
String keyOfSchemeList;

Expand Down

0 comments on commit 2dcc3f0

Please sign in to comment.