Waterfall/BungeeCord-Patches/0016-Micro-optimizations.patch
Shane Freeder 8fb8b6cd2c
Updated Upstream (BungeeCord)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

BungeeCord Changes:
a64c34d2 #2875: Add the MessageRaw channel
1d40b8a8 #2866: Add support for contents in Hover Event
2020-07-01 10:39:43 +01:00

48 lines
2.5 KiB
Diff

From bfd2fff8357922fce281d103a2db48a82e59c659 Mon Sep 17 00:00:00 2001
From: Tux <write@imaginarycode.com>
Date: Tue, 19 Jan 2016 15:13:29 -0700
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).
- 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
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 bcb229c3..b9d624f8 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -557,7 +557,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/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
index 200166d1..1ee9510b 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
@@ -245,7 +245,6 @@ public class DownstreamBridge extends PacketHandler
@Override
public void handle(PluginMessage pluginMessage) throws Exception
{
- DataInput in = pluginMessage.getStream();
PluginMessageEvent event = new PluginMessageEvent( server, con, pluginMessage.getTag(), pluginMessage.getData().clone() );
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
@@ -272,6 +271,7 @@ public class DownstreamBridge extends PacketHandler
if ( pluginMessage.getTag().equals( "BungeeCord" ) )
{
+ DataInput in = pluginMessage.getStream();
ByteArrayDataOutput out = ByteStreams.newDataOutput();
String subChannel = in.readUTF();
--
2.27.0