summaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorHarvey Harrison <[email protected]>2014-05-17 08:33:54 -0700
committerHarvey Harrison <[email protected]>2014-05-17 08:38:03 -0700
commit274dbc38e4b671579a07cce8bf7ecab6520e22d6 (patch)
tree5686e0b34f8ea68105014acc092075273eb9f1ca /src/java
parent0f9fb62d90c27312dfd6e98acbf78a2f70061d1a (diff)
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 <[email protected]>
Diffstat (limited to 'src/java')
-rw-r--r--src/java/com/jogamp/gluegen/GlueGen.java28
1 files changed, 17 insertions, 11 deletions
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<String> emittedDefines = new HashSet<String>(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<String> aliases = def.getAliases();
if (aliases != null) {
- comment = "Alias for: <code>";
+ comment.append("Alias for: <code>");
for (String alias : aliases) {
- comment += " " + alias;
+ comment.append(" ").append(alias);
}
- comment += "</code>";
+ comment.append("</code>");
}
if (def.getEnumName() != null) {
- String enumName = "Defined as part of enum type \"" + def.getEnumName() + "\"";
- if (comment == null) {
- comment = enumName;
- } else {
- comment += "<br>\n" + enumName;
- }
+ if (comment.length() > 0)
+ comment.append("<br>\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();