From 274dbc38e4b671579a07cce8bf7ecab6520e22d6 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Sat, 17 May 2014 08:33:54 -0700 Subject: gluegen: avoid appending Strings in a loop, pull out a Stringbuilder we can reuse Reuse a single stringbuilder to build all the comment strings and emit them if required. Signed-off-by: Harvey Harrison --- src/java/com/jogamp/gluegen/GlueGen.java | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/java/com/jogamp/gluegen/GlueGen.java b/src/java/com/jogamp/gluegen/GlueGen.java index 6a2b854..54e510d 100644 --- a/src/java/com/jogamp/gluegen/GlueGen.java +++ b/src/java/com/jogamp/gluegen/GlueGen.java @@ -216,27 +216,33 @@ public class GlueGen implements GlueEmitterControls { emit.beginDefines(); Set emittedDefines = new HashSet(100); // emit java equivalent of enum { ... } statements + StringBuilder comment = new StringBuilder(); for (ConstantDefinition def : constants) { if (!emittedDefines.contains(def.getName())) { emittedDefines.add(def.getName()); - String comment = null; Set aliases = def.getAliases(); if (aliases != null) { - comment = "Alias for: "; + comment.append("Alias for: "); for (String alias : aliases) { - comment += " " + alias; + comment.append(" ").append(alias); } - comment += ""; + comment.append(""); } if (def.getEnumName() != null) { - String enumName = "Defined as part of enum type \"" + def.getEnumName() + "\""; - if (comment == null) { - comment = enumName; - } else { - comment += "
\n" + enumName; - } + if (comment.length() > 0) + comment.append("
\n"); + + comment.append("Defined as part of enum type \""); + comment.append(def.getEnumName()); + comment.append("\""); + } + if (comment.length() > 0) { + emit.emitDefine(def, comment.toString()); + comment.setLength(0); + } + else { + emit.emitDefine(def, null); } - emit.emitDefine(def, comment); } } emit.endDefines(); -- cgit v1.2.3