diff options
author | Lars Vogel | 2019-06-19 15:23:58 +0000 |
---|---|---|
committer | Lars Vogel | 2019-06-21 08:52:41 +0000 |
commit | 0ee11246ee44dc773a8a91a6fb1b18864a781708 (patch) | |
tree | ce4fb33e0a37b45b86a7dbb9d33c1b8b7ad4a280 | |
parent | b1ecd006bfe55fc077015cc7ddece8825e013d9f (diff) | |
download | rt.equinox.bundles-I20190627-0135.tar.gz rt.equinox.bundles-I20190627-0135.tar.xz rt.equinox.bundles-I20190627-0135.zip |
Small String optimizationY20190708-0900Y20190705-0620Y20190704-0900Y20190701-0635Y20190628-1440Y20190627-0630Y20190627-0200Y20190627-0045I20190708-1035I20190708-0800I20190707-1800I20190707-0110I20190706-1800I20190705-1800I20190704-1800I20190704-0245I20190703-1800I20190703-0640I20190702-1800I20190702-0930I20190702-0610I20190701-1805I20190630-1800I20190629-1800I20190628-1800I20190627-1800I20190627-0135I20190626-1800I20190626-0720I20190625-1800I20190625-0535I20190624-1800I20190623-1800I20190621-1800
Useless toString call in String concatination
Using String.valueOf instead of ""+
Use faster indexof('') version
Change-Id: I991e0fe67138c3e7e35090ac9c23be687e75b417
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
18 files changed, 28 insertions, 28 deletions
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java index 3beee5787..acf5231fa 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java +++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java @@ -218,7 +218,7 @@ public abstract class PlatformURLConnection extends URLConnection { } protected void debug(String s) { - System.out.println("URL " + getURL().toString() + "^" + Integer.toHexString(Thread.currentThread().hashCode()) + " " + s); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + System.out.println("URL " + getURL() + "^" + Integer.toHexString(Thread.currentThread().hashCode()) + " " + s); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } private static void debugStartup(String s) { @@ -299,9 +299,9 @@ public abstract class PlatformURLConnection extends URLConnection { isInCache = true; } else { // attempt to cache - int ix = file.lastIndexOf("/"); //$NON-NLS-1$ + int ix = file.lastIndexOf('/'); //$NON-NLS-1$ tmp = file.substring(ix + 1); - tmp = cacheLocation + filePrefix + Long.toString((new java.util.Date()).getTime()) + "_" + tmp; //$NON-NLS-1$ + tmp = cacheLocation + filePrefix + (new java.util.Date()).getTime() + "_" + tmp; //$NON-NLS-1$ tmp = tmp.replace(File.separatorChar, '/'); if (isJar) { tmp = PlatformURLHandler.FILE + PlatformURLHandler.PROTOCOL_SEPARATOR + tmp + PlatformURLHandler.JAR_SEPARATOR + jarEntry; diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLHandler.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLHandler.java index 122b1f1c9..16da49af1 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLHandler.java +++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLHandler.java @@ -51,7 +51,7 @@ public class PlatformURLHandler extends AbstractURLStreamHandlerService { String spec = url.getFile().trim(); if (spec.startsWith("/")) //$NON-NLS-1$ spec = spec.substring(1); - int ix = spec.indexOf("/"); //$NON-NLS-1$ + int ix = spec.indexOf('/'); //$NON-NLS-1$ if (ix == -1) throw new MalformedURLException(NLS.bind(CommonMessages.url_invalidURL, url.toExternalForm())); diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLFragmentConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLFragmentConnection.java index 5d7732d2b..f06d296ca 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLFragmentConnection.java +++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLFragmentConnection.java @@ -49,7 +49,7 @@ public class PlatformURLFragmentConnection extends PlatformURLConnection { spec = spec.substring(1); if (!spec.startsWith(FRAGMENT)) throw new IOException(NLS.bind(CommonMessages.url_badVariant, url)); - int ix = spec.indexOf("/", FRAGMENT.length() + 1); //$NON-NLS-1$ + int ix = spec.indexOf('/', FRAGMENT.length() + 1); //$NON-NLS-1$ String ref = ix == -1 ? spec.substring(FRAGMENT.length() + 1) : spec.substring(FRAGMENT.length() + 1, ix); String id = getId(ref); Activator activator = Activator.getDefault(); diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLMetaConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLMetaConnection.java index f8c948141..b86d55885 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLMetaConnection.java +++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLMetaConnection.java @@ -40,7 +40,7 @@ public class PlatformURLMetaConnection extends PlatformURLConnection { spec = spec.substring(1); if (!spec.startsWith(META)) throw new IOException(NLS.bind(CommonMessages.url_badVariant, url.toString())); - int ix = spec.indexOf("/", META.length() + 1); //$NON-NLS-1$ + int ix = spec.indexOf('/', META.length() + 1); //$NON-NLS-1$ String ref = ix == -1 ? spec.substring(META.length() + 1) : spec.substring(META.length() + 1, ix); String id = getId(ref); Activator activator = Activator.getDefault(); diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLPluginConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLPluginConnection.java index 47f1a3f8e..c371d120c 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLPluginConnection.java +++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLPluginConnection.java @@ -53,7 +53,7 @@ public class PlatformURLPluginConnection extends PlatformURLConnection { spec = spec.substring(1); if (!spec.startsWith(PLUGIN)) throw new IOException(NLS.bind(CommonMessages.url_badVariant, originalURL)); - int ix = spec.indexOf("/", PLUGIN.length() + 1); //$NON-NLS-1$ + int ix = spec.indexOf('/', PLUGIN.length() + 1); //$NON-NLS-1$ String ref = ix == -1 ? spec.substring(PLUGIN.length() + 1) : spec.substring(PLUGIN.length() + 1, ix); String id = getId(ref); Activator activator = Activator.getDefault(); diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java index 1f4cdb1fa..d997ee1b0 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java +++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java @@ -60,7 +60,7 @@ public class ReferenceHashSet<T> { Object referent = super.get(); if (referent == null) return "[hashCode=" + this.hashCode + "] <referent was garbage collected>"; //$NON-NLS-1$ //$NON-NLS-2$ - return "[hashCode=" + this.hashCode + "] " + referent.toString(); //$NON-NLS-1$ //$NON-NLS-2$ + return "[hashCode=" + this.hashCode + "] " + referent; //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -94,7 +94,7 @@ public class ReferenceHashSet<T> { Object referent = super.get(); if (referent == null) return "[hashCode=" + this.hashCode + "] <referent was garbage collected>"; //$NON-NLS-1$ //$NON-NLS-2$ - return "[hashCode=" + this.hashCode + "] " + referent.toString(); //$NON-NLS-1$ //$NON-NLS-2$ + return "[hashCode=" + this.hashCode + "] " + referent; //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -312,7 +312,7 @@ public class ReferenceHashSet<T> { if (value != null) { Object ref = value.get(); if (ref != null) { - buffer.append(ref.toString()); + buffer.append(ref); buffer.append(", "); //$NON-NLS-1$ } } diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java index 0818f6f98..5ff5fe7b1 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java +++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java @@ -319,7 +319,7 @@ public class Path implements IPath, Cloneable { @Override public IPath append(String tail) { //optimize addition of a single segment - if (tail.indexOf(SEPARATOR) == -1 && !tail.contains("\\") && tail.indexOf(DEVICE_SEPARATOR) == -1) { //$NON-NLS-1$ + if (tail.indexOf(SEPARATOR) == -1 && tail.indexOf('\\') == -1 && tail.indexOf(DEVICE_SEPARATOR) == -1) { //$NON-NLS-1$ int tailLength = tail.length(); if (tailLength < 3) { //some special cases diff --git a/bundles/org.eclipse.equinox.concurrent/src/org/eclipse/equinox/concurrent/future/ThreadsExecutor.java b/bundles/org.eclipse.equinox.concurrent/src/org/eclipse/equinox/concurrent/future/ThreadsExecutor.java index 5ecd8c356..89302754b 100644 --- a/bundles/org.eclipse.equinox.concurrent/src/org/eclipse/equinox/concurrent/future/ThreadsExecutor.java +++ b/bundles/org.eclipse.equinox.concurrent/src/org/eclipse/equinox/concurrent/future/ThreadsExecutor.java @@ -39,7 +39,7 @@ public class ThreadsExecutor extends AbstractExecutor { } protected String createThreadName(IProgressRunnable<?> runnable) { - return "ThreadsExecutor(" + runnable.toString() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + return "ThreadsExecutor(" + runnable + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } /** diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java index e58e98639..b0e325324 100755 --- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java +++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java @@ -311,7 +311,7 @@ public class Activator implements BundleActivator { dict.put("osgi.command.scope", "equinox"); String[] methodNames = new String[commandMethods.length]; for (int i = 0; i < commandMethods.length; i++) { - String methodName = "" + commandMethods[i].getName().substring(1); + String methodName = commandMethods[i].getName().substring(1); methodNames[i] = methodName; } diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter.java index b21f88fd6..09a429b20 100755 --- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter.java +++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter.java @@ -214,7 +214,7 @@ public void printBundleResource(Bundle bundle, String resource) { System.err.println(e); } } else { - println("CONSOLE_RESOURCE ["+resource+"] NOT_IN_BUNDLE " + bundle.toString()); + println("CONSOLE_RESOURCE ["+resource+"] NOT_IN_BUNDLE " + bundle); } } diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/CommandsTracker.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/CommandsTracker.java index f4c1e2a5e..89cddec58 100755 --- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/CommandsTracker.java +++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/CommandsTracker.java @@ -57,10 +57,10 @@ public class CommandsTracker { synchronized (lock) { if (function.getClass().isArray()) { for (Object func : ((Object[]) function)) { - commandNames.add(scope.toString() + ":" + func.toString()); + commandNames.add(scope + ":" + func); } } else { - commandNames.add(scope.toString() + ":" + function.toString()); + commandNames.add(scope + ":" + function); } return commandNames; } @@ -80,10 +80,10 @@ public class CommandsTracker { if (scope != null && function != null) { if (!function.getClass().isArray()) { - commandNames.remove(scope.toString() + ":" + function.toString()); + commandNames.remove(scope + ":" + function); } else { for (Object func : (Object[]) function) { - commandNames.remove(scope.toString() + ":" + func.toString()); + commandNames.remove(scope + ":" + func); } } } diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java index fbb1ef010..b07c67a65 100755 --- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java +++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java @@ -1247,7 +1247,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { if (envInfo != null) { System.out.println(ConsoleMsg.CONSOLE_SETTING_PROPERTIES_TITLE); for(String argument : arguments) { - int index = argument.indexOf("="); + int index = argument.indexOf('='); if(index > -1) { String key = argument.substring(0, index); String value = argument.substring(index + 1, argument.length()); diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandsConverter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandsConverter.java index d4c64e660..cee89de6d 100755 --- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandsConverter.java +++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandsConverter.java @@ -78,7 +78,7 @@ public class EquinoxCommandsConverter implements Converter { // check for @ -- this may separate either the version string, or be part of the // location - int ix = symbolicName.indexOf("@"); //$NON-NLS-1$ + int ix = symbolicName.indexOf('@'); //$NON-NLS-1$ if (ix != -1) { if ((ix + 1) != symbolicName.length()) { try { @@ -174,7 +174,7 @@ public class EquinoxCommandsConverter implements Converter { StringBuilder builder = new StringBuilder(); for (i = 0; i < count; i++) { - builder.append(" " + keys[i] + " = " + dic.get(keys[i])); //$NON-NLS-1$//$NON-NLS-2$ + builder.append(" ").append(keys[i]).append(" = ").append(dic.get(keys[i])); //$NON-NLS-1$//$NON-NLS-2$ builder.append("\r\n"); } builder.append("\r\n"); diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/Util.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/Util.java index 46197dc6f..32b394975 100755 --- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/Util.java +++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/Util.java @@ -202,10 +202,10 @@ public class Util { StringBuilder stringBuffer = new StringBuilder(length); if (onLeft) - stringBuffer.append(padding.toString()); + stringBuffer.append(padding); stringBuffer.append(input); if (!onLeft) - stringBuffer.append(padding.toString()); + stringBuffer.append(padding); return stringBuffer.toString(); } } diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CommandNamesCompleter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CommandNamesCompleter.java index a73b0a57c..81f163b35 100755 --- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CommandNamesCompleter.java +++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CommandNamesCompleter.java @@ -73,7 +73,7 @@ public class CommandNamesCompleter implements Completer { Set<String> clearedCommandNames = new HashSet<>(); for(String commandName : commandNames) { - clearedCommandNames.add(commandName.substring(commandName.indexOf(":") + 1)); + clearedCommandNames.add(commandName.substring(commandName.indexOf(':') + 1)); } return clearedCommandNames; diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetCommand.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetCommand.java index 21108747e..05ae84f7c 100755 --- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetCommand.java +++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetCommand.java @@ -76,7 +76,7 @@ public class TelnetCommand { String telnetPort = null; String consolePropValue = context.getProperty(CONSOLE_PROP); if(consolePropValue != null) { - int index = consolePropValue.lastIndexOf(":"); + int index = consolePropValue.lastIndexOf(':'); if (index > -1) { defaultHost = consolePropValue.substring(0, index); } diff --git a/bundles/org.eclipse.equinox.util/src/org/eclipse/equinox/internal/util/impl/tpt/timer/TimerImpl.java b/bundles/org.eclipse.equinox.util/src/org/eclipse/equinox/internal/util/impl/tpt/timer/TimerImpl.java index 7c2aadc70..30b27a6d9 100644 --- a/bundles/org.eclipse.equinox.util/src/org/eclipse/equinox/internal/util/impl/tpt/timer/TimerImpl.java +++ b/bundles/org.eclipse.equinox.util/src/org/eclipse/equinox/internal/util/impl/tpt/timer/TimerImpl.java @@ -58,7 +58,7 @@ public class TimerImpl implements Runnable { } th.start(); } catch (Exception e) { - throw new RuntimeException("Can not start Timer thread!" + e.toString()); + throw new RuntimeException("Can not start Timer thread!" + e); } } diff --git a/bundles/org.eclipse.equinox.util/src/org/eclipse/equinox/internal/util/ref/Log.java b/bundles/org.eclipse.equinox.util/src/org/eclipse/equinox/internal/util/ref/Log.java index 0f54a8a77..0e73cb620 100644 --- a/bundles/org.eclipse.equinox.util/src/org/eclipse/equinox/internal/util/ref/Log.java +++ b/bundles/org.eclipse.equinox.util/src/org/eclipse/equinox/internal/util/ref/Log.java @@ -630,14 +630,14 @@ public class Log implements LogInterface, ServiceTrackerCustomizer<LogService, L StringBuilder sBuf = new StringBuilder(prefix).append("["); String module = getModuleName(moduleID); - sBuf.append(module != null ? module : "" + moduleID); + sBuf.append(module != null ? module : String.valueOf(moduleID)); sBuf.append(chars, 0, 2); if (msgID != 0) { // map msgID to String String msg = getMsgValue(msgID); - sBuf.append(msg != null ? msg : "" + msgID); + sBuf.append(msg != null ? msg : String.valueOf(msgID)); } if (message != null) |