2016-10-30 15:46:05 +01:00
From 34ee7df4a7d9f451768b737f00747c635e4e3d7b Mon Sep 17 00:00:00 2001
2016-05-28 18:34:39 +02:00
From: Tux <write@imaginarycode.com>
Date: Thu, 19 May 2016 18:05:33 -0600
Subject: [PATCH] Micro-optimizations
- PluginManager.dispatchCommand() avoids regex while splitting commands. Java 7 introduced an optimized String.split() that should be used instead (affects command dispatch).
- Avoid regex in getLocale() by changing from replaceAll(String, String) to replaceAll(char, char)
diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java
2016-08-28 22:23:49 +02:00
index 71a5a15..520ee31 100644
2016-05-28 18:34:39 +02:00
--- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java
+++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java
@@ -42,7 +42,6 @@ import org.yaml.snakeyaml.introspector.PropertyUtils;
public class PluginManager
{
- private static final Pattern argsSplit = Pattern.compile( " " );
/*========================================================================*/
private final ProxyServer proxy;
/*========================================================================*/
@@ -126,7 +125,7 @@ public class PluginManager
*/
public boolean dispatchCommand(CommandSender sender, String commandLine, List<String> tabResults)
{
- String[] split = argsSplit.split( commandLine, -1 );
+ String[] split = commandLine.split(" ", -1);
// Check for chat that only contains " "
if ( split.length == 0 )
{
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
2016-10-30 15:46:05 +01:00
index 780ad9f..042dab3 100644
2016-05-28 18:34:39 +02:00
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
2016-10-30 15:46:05 +01:00
@@ -551,7 +551,7 @@ public final class UserConnection implements ProxiedPlayer
2016-05-28 18:34:39 +02:00
@Override
public Locale getLocale()
{
- return ( locale == null && settings != null ) ? locale = Locale.forLanguageTag( settings.getLocale().replaceAll( "_", "-" ) ) : locale;
+ return ( locale == null && settings != null ) ? locale = Locale.forLanguageTag( settings.getLocale().replace( '_', '-' ) ) : locale;
}
@Override
--
2016-10-25 18:57:11 +02:00
2.7.4 (Apple Git-66)
2016-05-28 18:34:39 +02:00