ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r932588 - /ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java
Date Fri, 09 Apr 2010 20:37:46 GMT
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;
         }



Mime
View raw message