From e1abfbb6c15b54b7595115602656465f548ee959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Br=C3=A9gier?= Date: Thu, 22 May 2014 09:15:20 +0200 Subject: [PATCH] Correction on StringBuilder default init size Motivation: The default StringBuilder size is too small (data.length + 4) while it will be 2*data.length (byte to Hex) + 5 "-" char (since 5 peaces appended). Modification: Changing initial size to the correct one Result: Allocation of the correct final size from the beginning for this StringBuilder. --- transport/src/main/java/io/netty/channel/DefaultChannelId.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelId.java b/transport/src/main/java/io/netty/channel/DefaultChannelId.java index 5c6dcf4ed1..0e7b674490 100644 --- a/transport/src/main/java/io/netty/channel/DefaultChannelId.java +++ b/transport/src/main/java/io/netty/channel/DefaultChannelId.java @@ -423,7 +423,7 @@ final class DefaultChannelId implements ChannelId { } private String newLongValue() { - StringBuilder buf = new StringBuilder(data.length + 4); + StringBuilder buf = new StringBuilder(2 * data.length + 5); int i = 0; i = appendHexDumpField(buf, i, MACHINE_ID_LEN); i = appendHexDumpField(buf, i, PROCESS_ID_LEN);