From 0da141d414492543bf014e63528bc325300b57e8 Mon Sep 17 00:00:00 2001 From: eutarass Date: Thu, 6 May 2010 22:42:03 +0000 Subject: TCF Core: minor performance improvement in discovery protocol implementation --- .../tm/internal/tcf/services/local/LocatorService.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'plugins/org.eclipse.tm.tcf.core') diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/local/LocatorService.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/local/LocatorService.java index 98c6d68bd..c61add16e 100644 --- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/local/LocatorService.java +++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/local/LocatorService.java @@ -568,14 +568,17 @@ public class LocatorService implements ILocator { try { out_buf[4] = CONF_PEER_INFO; int i = 8; + StringBuffer sb = new StringBuffer(out_buf.length); for (String key : attrs.keySet()) { - String s = key + "=" + attrs.get(key); - byte[] bt = s.getBytes("UTF-8"); - if (i + bt.length >= out_buf.length) break; - System.arraycopy(bt, 0, out_buf, i, bt.length); - i += bt.length; - out_buf[i++] = 0; - } + sb.append(key); + sb.append('='); + sb.append(attrs.get(key)); + sb.append((char)0); + } + byte[] bt = sb.toString().getBytes("UTF-8"); + if (i + bt.length > out_buf.length) return; + System.arraycopy(bt, 0, out_buf, i, bt.length); + i += bt.length; for (SubNet subnet : subnets) { if (peer instanceof RemotePeer) { -- cgit v1.2.3