From 900b2a73b2d0b6f934718ac88015151c5bf7ccb8 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 16 Apr 2012 00:13:17 +0200 Subject: StringBuffer -> StringBuilder (Local objects, no concurrency) --- .../com/jogamp/gluegen/cgram/CSymbolTable.java | 25 +++++++++++----------- src/java/com/jogamp/gluegen/cgram/LineObject.java | 4 ++-- .../gluegen/cgram/PreprocessorInfoChannel.java | 20 ++++++++--------- src/java/com/jogamp/gluegen/cgram/TNode.java | 4 ++-- .../com/jogamp/gluegen/cgram/types/ArrayType.java | 2 +- .../jogamp/gluegen/cgram/types/CompoundType.java | 2 +- .../jogamp/gluegen/cgram/types/FunctionType.java | 2 +- 7 files changed, 29 insertions(+), 30 deletions(-) (limited to 'src/java/com/jogamp/gluegen/cgram') diff --git a/src/java/com/jogamp/gluegen/cgram/CSymbolTable.java b/src/java/com/jogamp/gluegen/cgram/CSymbolTable.java index 0addf7b..2f25e75 100644 --- a/src/java/com/jogamp/gluegen/cgram/CSymbolTable.java +++ b/src/java/com/jogamp/gluegen/cgram/CSymbolTable.java @@ -5,18 +5,17 @@ import java.util.Hashtable; import java.util.Enumeration; - public class CSymbolTable { /** holds list of scopes */ - private Vector scopeStack; + private Vector scopeStack; /** table where all defined names are mapped to TNode tree nodes */ - private Hashtable symTable; + private Hashtable symTable; public CSymbolTable() { - scopeStack = new Vector(10); - symTable = new Hashtable(533); + scopeStack = new Vector(10); + symTable = new Hashtable(533); } @@ -39,9 +38,9 @@ public class CSymbolTable { /** return the current scope as a string */ public String currentScopeAsString() { - StringBuffer buf = new StringBuffer(100); + StringBuilder buf = new StringBuilder(100); boolean first = true; - Enumeration e = scopeStack.elements(); + Enumeration e = scopeStack.elements(); while(e.hasMoreElements()) { if(first) first = false; @@ -85,13 +84,13 @@ public class CSymbolTable { /** add a node to the table with it's key as the current scope and the name */ public TNode add(String name, TNode node) { - return (TNode)symTable.put(addCurrentScopeToName(name),node); + return symTable.put(addCurrentScopeToName(name),node); } /** lookup a fully scoped name in the symbol table */ public TNode lookupScopedName(String scopedName) { - return (TNode)symTable.get(scopedName); + return symTable.get(scopedName); } /** lookup an unscoped name in the table by prepending @@ -108,7 +107,7 @@ public class CSymbolTable { while (tnode == null && scope != null) { scopedName = addScopeToName(scope, name); //System.out.println("lookup trying " + scopedName); - tnode = (TNode)symTable.get(scopedName); + tnode = symTable.get(scopedName); scope = removeOneLevelScope(scope); } return tnode; @@ -116,11 +115,11 @@ public class CSymbolTable { /** convert this table to a string */ public String toString() { - StringBuffer buff = new StringBuffer(300); + StringBuilder buff = new StringBuilder(300); buff.append("CSymbolTable { \nCurrentScope: " + currentScopeAsString() + "\nDefinedSymbols:\n"); - Enumeration ke = symTable.keys(); - Enumeration ve = symTable.elements(); + Enumeration ke = symTable.keys(); + Enumeration ve = symTable.elements(); while(ke.hasMoreElements()) { buff.append(ke.nextElement().toString() + " (" + TNode.getNameForType(((TNode)ve.nextElement()).getType()) + ")\n"); diff --git a/src/java/com/jogamp/gluegen/cgram/LineObject.java b/src/java/com/jogamp/gluegen/cgram/LineObject.java index c03b3e8..5104497 100644 --- a/src/java/com/jogamp/gluegen/cgram/LineObject.java +++ b/src/java/com/jogamp/gluegen/cgram/LineObject.java @@ -106,8 +106,8 @@ class LineObject { } public String toString() { - StringBuffer ret; - ret = new StringBuffer("# " + line + " \"" + source + "\""); + StringBuilder ret; + ret = new StringBuilder("# " + line + " \"" + source + "\""); if (enteringFile) { ret.append(" 1"); } diff --git a/src/java/com/jogamp/gluegen/cgram/PreprocessorInfoChannel.java b/src/java/com/jogamp/gluegen/cgram/PreprocessorInfoChannel.java index 5e7018f..5281ab1 100644 --- a/src/java/com/jogamp/gluegen/cgram/PreprocessorInfoChannel.java +++ b/src/java/com/jogamp/gluegen/cgram/PreprocessorInfoChannel.java @@ -4,18 +4,18 @@ import java.util.*; public class PreprocessorInfoChannel { - Hashtable lineLists = new Hashtable(); // indexed by Token number + Hashtable> lineLists = new Hashtable>(); // indexed by Token number int firstValidTokenNumber = 0; int maxTokenNumber = 0; public void addLineForTokenNumber( Object line, Integer toknum ) { if ( lineLists.containsKey( toknum ) ) { - Vector lines = (Vector) lineLists.get( toknum ); + Vector lines = lineLists.get( toknum ); lines.addElement(line); } else { - Vector lines = new Vector(); + Vector lines = new Vector(); lines.addElement(line); lineLists.put(toknum, lines); if ( maxTokenNumber < toknum.intValue() ) { @@ -29,16 +29,16 @@ public class PreprocessorInfoChannel return maxTokenNumber; } - public Vector extractLinesPrecedingTokenNumber( Integer toknum ) + public Vector extractLinesPrecedingTokenNumber( Integer toknum ) { - Vector lines = new Vector(); + Vector lines = new Vector(); if (toknum == null) return lines; for (int i = firstValidTokenNumber; i < toknum.intValue(); i++){ Integer inti = new Integer(i); if ( lineLists.containsKey( inti ) ) { - Vector tokenLineVector = (Vector) lineLists.get( inti ); + Vector tokenLineVector = lineLists.get( inti ); if ( tokenLineVector != null) { - Enumeration tokenLines = tokenLineVector.elements(); + Enumeration tokenLines = tokenLineVector.elements(); while ( tokenLines.hasMoreElements() ) { lines.addElement( tokenLines.nextElement() ); } @@ -52,13 +52,13 @@ public class PreprocessorInfoChannel public String toString() { - StringBuffer sb = new StringBuffer("PreprocessorInfoChannel:\n"); + StringBuilder sb = new StringBuilder("PreprocessorInfoChannel:\n"); for (int i = 0; i <= maxTokenNumber + 1; i++){ Integer inti = new Integer(i); if ( lineLists.containsKey( inti ) ) { - Vector tokenLineVector = (Vector) lineLists.get( inti ); + Vector tokenLineVector = lineLists.get( inti ); if ( tokenLineVector != null) { - Enumeration tokenLines = tokenLineVector.elements(); + Enumeration tokenLines = tokenLineVector.elements(); while ( tokenLines.hasMoreElements() ) { sb.append(inti + ":" + tokenLines.nextElement() + '\n'); } diff --git a/src/java/com/jogamp/gluegen/cgram/TNode.java b/src/java/com/jogamp/gluegen/cgram/TNode.java index e9185f9..f7feecc 100644 --- a/src/java/com/jogamp/gluegen/cgram/TNode.java +++ b/src/java/com/jogamp/gluegen/cgram/TNode.java @@ -155,7 +155,7 @@ public void initialize(AST tr) { /** Returns the text for this node and all children */ public String getAllChildrenText() { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); buf.append(getText()); for (TNode node = (TNode) getFirstChild(); node != null; node = (TNode) node.getNextSibling()) { buf.append(node.getText()); @@ -304,7 +304,7 @@ public void initialize(AST tr) { /** return a short string representation of the node */ public String toString() { - StringBuffer str = new StringBuffer( getNameForType(getType()) + + StringBuilder str = new StringBuilder( getNameForType(getType()) + "[" + getText() + ", " + "]"); if(this.getLineNum() != 0) diff --git a/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java b/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java index 4ede5aa..7bd7d42 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java @@ -111,7 +111,7 @@ public class ArrayType extends MemoryLayoutType implements Cloneable { } public String toString(String variableName) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); buf.append(elementType.getName()); if (variableName != null) { buf.append(" "); diff --git a/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java b/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java index 7a4b45d..a4b419f 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java @@ -206,7 +206,7 @@ public abstract class CompoundType extends MemoryLayoutType implements Cloneable try { visiting = true; String kind = (isStruct() ? "struct {" : "union {"); - StringBuffer res = new StringBuffer(); + StringBuilder res = new StringBuilder(); res.append(kind); int n = getNumFields(); for (int i = 0; i < n; i++) { diff --git a/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java b/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java index cb430db..4c908dc 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java +++ b/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java @@ -134,7 +134,7 @@ public class FunctionType extends Type implements Cloneable { } String toString(String functionName, String callingConvention, boolean emitNativeTag, boolean isPointer) { - StringBuffer res = new StringBuffer(); + StringBuilder res = new StringBuilder(); res.append(getReturnType()); res.append(" "); if (isPointer) { -- cgit v1.2.3