Small String optimization

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>
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 3beee57..acf5231 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 @@
 	}
 
 	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 @@
 			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 122b1f1..16da49a 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 @@
 		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 5d7732d..f06d296 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 @@
 			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 f8c9481..b86d558 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 @@
 			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 47f1a3f..c371d12 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 @@
 			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 1f4cdb1..d997ee1 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 @@
 			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 @@
 			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 @@
 			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 0818f6f..5ff5fe7 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 @@
 	@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 5ecd8c3..8930275 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 @@
 	}
 
 	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 e58e986..b0e3253 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 @@
 		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 b21f88f..09a429b 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 @@
         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 f4c1e2a..89cddec 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 @@
         		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 @@
 
             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 fbb1ef0..b07c67a 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 @@
 				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 d4c64e6..cee89de 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 @@
 
 				// 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 @@
 		
 		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 46197dc..32b3949 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 @@
 
 		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 a73b0a5..81f163b 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 @@
 		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 2110874..05ae84f 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 @@
     	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 7c2aadc..30b27a6 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 @@
 			}
 			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 0f54a8a..0e73cb6 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 @@
 		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)