mirror of
https://github.com/PaperMC/Waterfall.git
synced 2025-01-05 15:38:11 +01:00
e1553a3f25
Since Waterfall is now using Log4J for logging, these patches no longer have any effect.
84 lines
4.4 KiB
Diff
84 lines
4.4 KiB
Diff
From 5abce36d076e7384cfac4a0659d3d95e8dc1d05c Mon Sep 17 00:00:00 2001
|
|
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)
|
|
- Don't attempt to format arguments when there are none provided
|
|
- Don't create a data input stream for every plugin message we get from servers
|
|
- Optimise replacing dashes in UUID's
|
|
|
|
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
|
|
index 71a5a158..520ee315 100644
|
|
--- 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/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
|
index c03941ed..226af98b 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
|
@@ -493,7 +493,9 @@ public class BungeeCord extends ProxyServer
|
|
String translation = "<translation '" + name + "' missing>";
|
|
try
|
|
{
|
|
- translation = MessageFormat.format( customBundle != null && customBundle.containsKey( name ) ? customBundle.getString( name ) : baseBundle.getString( name ), args );
|
|
+ final String string = customBundle != null && customBundle.containsKey( name ) ? customBundle.getString( name ) : baseBundle.getString( name );
|
|
+
|
|
+ translation = ( args.length == 0 ) ? string : MessageFormat.format( string, args );
|
|
} catch ( MissingResourceException ex )
|
|
{
|
|
}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
index 74c5a089..28e79933 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
@@ -546,7 +546,7 @@ public final class UserConnection implements ProxiedPlayer
|
|
@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
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
index a92b806c..19fd3b3b 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
@@ -222,7 +222,6 @@ public class DownstreamBridge extends PacketHandler
|
|
@Override
|
|
public void handle(PluginMessage pluginMessage) throws Exception
|
|
{
|
|
- DataInput in = pluginMessage.getStream();
|
|
PluginMessageEvent event = new PluginMessageEvent( con.getServer(), con, pluginMessage.getTag(), pluginMessage.getData().clone() );
|
|
|
|
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
|
@@ -249,6 +248,7 @@ public class DownstreamBridge extends PacketHandler
|
|
|
|
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
|
|
{
|
|
+ DataInput in = pluginMessage.getStream();
|
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
|
String subChannel = in.readUTF();
|
|
|
|
--
|
|
2.14.1
|
|
|