From 1da1fe8002a4b8a6330552900a892f899b89c328 Mon Sep 17 00:00:00 2001 From: sharwell Date: Thu, 17 Nov 2011 18:33:20 -0800 Subject: [PATCH] v4: remove unnecessary casts [git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9362] --- .../Java/src/org/antlr/v4/runtime/tree/BaseAST.java | 4 ++-- .../org/antlr/v4/runtime/tree/BaseASTAdaptor.java | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/BaseAST.java b/runtime/Java/src/org/antlr/v4/runtime/tree/BaseAST.java index c0abee565..07062e52e 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/tree/BaseAST.java +++ b/runtime/Java/src/org/antlr/v4/runtime/tree/BaseAST.java @@ -95,7 +95,7 @@ public abstract class BaseAST implements AST { if ( t==null ) { return; // do nothing upon addChild(null) } - BaseAST childTree = (BaseAST)t; + BaseAST childTree = t; if ( childTree.isNil() ) { // t is an empty node possibly with children if ( this.children!=null && this.children == childTree.children ) { throw new RuntimeException("attempt to add child list to itself"); @@ -240,7 +240,7 @@ public abstract class BaseAST implements AST { public void freshenParentAndChildIndexesDeeply(int offset) { int n = getChildCount(); for (int c = offset; c < n; c++) { - BaseAST child = (BaseAST)getChild(c); + BaseAST child = getChild(c); child.setChildIndex(c); child.setParent(this); child.freshenParentAndChildIndexesDeeply(); diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/BaseASTAdaptor.java b/runtime/Java/src/org/antlr/v4/runtime/tree/BaseASTAdaptor.java index 8d3479ef4..807855be6 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/tree/BaseASTAdaptor.java +++ b/runtime/Java/src/org/antlr/v4/runtime/tree/BaseASTAdaptor.java @@ -57,7 +57,7 @@ public abstract class BaseASTAdaptor implements ASTAdaptor @Override public boolean isNil(T tree) { - return ((AST)tree).isNil(); + return tree.isNil(); } @Override @@ -96,7 +96,7 @@ public abstract class BaseASTAdaptor implements ASTAdaptor @Override public void addChild(T t, T child) { if ( t!=null && child!=null ) { - ((BaseAST)t).addChild((BaseAST) child); + t.addChild(child); } } @@ -231,20 +231,20 @@ public abstract class BaseASTAdaptor implements ASTAdaptor @Override public int getChildCount(T t) { - return ((BaseAST)t).getChildCount(); + return t.getChildCount(); } @Override public int getUniqueID(T node) { if ( treeToUniqueIDMap==null ) { - treeToUniqueIDMap = new HashMap(); + treeToUniqueIDMap = new HashMap(); } - Integer prevID = (Integer)treeToUniqueIDMap.get(node); + Integer prevID = treeToUniqueIDMap.get(node); if ( prevID!=null ) { return prevID; } int ID = uniqueNodeID; - treeToUniqueIDMap.put((BaseAST)node, ID); + treeToUniqueIDMap.put(node, ID); uniqueNodeID++; return ID; // GC makes these nonunique: