From eef83a04aae7c166e3b1b4dad041711b205b0229 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Thu, 27 Jul 2017 09:22:24 -0700 Subject: [PATCH] Remove unnecessary getType() calls. --- src/org/nwapw/abacus/tree/TreeNode.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/org/nwapw/abacus/tree/TreeNode.java b/src/org/nwapw/abacus/tree/TreeNode.java index f028274..0cc5446 100644 --- a/src/org/nwapw/abacus/tree/TreeNode.java +++ b/src/org/nwapw/abacus/tree/TreeNode.java @@ -124,14 +124,15 @@ public abstract class TreeNode { public static TreeNode fromStringRecursive(String source, ArrayList> matches){ if(matches.size() == 0) return null; Match match = matches.remove(0); - if(match.getType() == TokenType.OP){ + TokenType matchType = match.getType(); + if(matchType == TokenType.OP){ TreeNode right = fromStringRecursive(source, matches); TreeNode left = fromStringRecursive(source, matches); if(left == null || right == null) return null; else return new OpNode(source.substring(match.getFrom(), match.getTo()), left, right); - } else if(match.getType() == TokenType.NUM){ + } else if(matchType == TokenType.NUM){ return new NumberNode(Double.parseDouble(source.substring(match.getFrom(), match.getTo()))); - } else if(match.getType() == TokenType.INTERNAL_FUNCTION_START){ + } else if(matchType == TokenType.INTERNAL_FUNCTION_START){ if(matches.isEmpty() || matches.get(0).getType() != TokenType.WORD) return null; Match stringName = matches.remove(0); String functionName = source.substring(stringName.getFrom(), stringName.getTo());