You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by mb...@apache.org on 2010/04/09 22:37:46 UTC

svn commit: r932588 - /ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java

Author: mbenson
Date: Fri Apr  9 20:37:46 2010
New Revision: 932588

URL: http://svn.apache.org/viewvc?rev=932588&view=rev
Log:
problems 49079, 48961

Address indexOf inefficiency in PropertyHelper default propertyexpander implementation.


Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java?rev=932588&r1=932587&r2=932588&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java Fri Apr  9 20:37:46 2010
@@ -188,14 +188,18 @@ public class PropertyHelper implements G
         public String parsePropertyName(
             String s, ParsePosition pos, ParseNextProperty notUsed) {
             int index = pos.getIndex();
-            if (s.indexOf("${", index) == index) {
-                int end = s.indexOf('}', index);
+            //directly check near, triggering characters:
+            if (s.length() - index >= 3
+                    && '$' == s.charAt(index) && '{' == s.charAt(index + 1)) {
+                int start = index + 2;
+                //defer to String.indexOf() for protracted check:
+                int end = s.indexOf('}', start);
                 if (end < 0) {
-                    throw new BuildException("Syntax error in property: " + s);
+                    throw new BuildException("Syntax error in property: "
+                            + s.substring(index));
                 }
-                int start = index + 2;
                 pos.setIndex(end + 1);
-                return s.substring(start, end);
+                return start == end ? "" :  s.substring(start, end);
             }
             return null;
         }