commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r617943 - /commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/AttributeContext.java
Date Sun, 03 Feb 2008 03:53:33 GMT
Author: mbenson
Date: Sat Feb  2 19:53:32 2008
New Revision: 617943

URL: http://svn.apache.org/viewvc?rev=617943&view=rev
Log:
avoid unnecessary object creation & method call

Modified:
    commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/AttributeContext.java

Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/AttributeContext.java
URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/AttributeContext.java?rev=617943&r1=617942&r2=617943&view=diff
==============================================================================
--- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/AttributeContext.java
(original)
+++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/AttributeContext.java
Sat Feb  2 19:53:32 2008
@@ -32,7 +32,7 @@
  * @version $Revision$ $Date$
  */
 public class AttributeContext extends EvalContext {
-    private static final NodeNameTest WILDCARD_TEST = new NodeNameTest(new QName(null, "*"));
+    private static final QName WILDCARD = new QName(null, "*");
 
     private NodeTest nodeTest;
     private boolean setStarted = false;
@@ -75,20 +75,22 @@
         super.setPosition(getCurrentPosition() + 1);
         if (!setStarted) {
             setStarted = true;
-            NodeNameTest nodeNameTest = null;
-            if (nodeTest instanceof NodeTypeTest) {
-                if (((NodeTypeTest) nodeTest).getNodeType() == Compiler.NODE_TYPE_NODE) {
-                    nodeNameTest = WILDCARD_TEST;
-                }
-            }
-            else if (nodeTest instanceof NodeNameTest) {
-                nodeNameTest = (NodeNameTest) nodeTest;
+            QName name;
+            if (nodeTest instanceof NodeNameTest) {
+                name = ((NodeNameTest) nodeTest).getNodeName();
             }
-            if (nodeNameTest == null) {
-                return false;
+            else {
+                if (nodeTest instanceof NodeTypeTest
+                        && ((NodeTypeTest) nodeTest).getNodeType() == Compiler.NODE_TYPE_NODE)
{
+                    name = WILDCARD;
+                }
+                else {
+                    iterator = null;
+                    return false;
+                }
             }
             iterator = parentContext.getCurrentNodePointer().attributeIterator(
-                    nodeNameTest.getNodeName());
+                    name);
         }
         if (iterator == null) {
             return false;



Mime
View raw message