From 16d4f876a8312de17bbd5b6ecb8efb53070c1882 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Fri, 9 Apr 2010 15:14:50 +0000 Subject: [PATCH] problems 49079, 48961 Address indexOf inefficiency in PropertyHelper embedded skip-double-dollar propertyexpander implementation. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@932456 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/PropertyHelper.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/org/apache/tools/ant/PropertyHelper.java b/src/main/org/apache/tools/ant/PropertyHelper.java index 082f2c702..422891575 100644 --- a/src/main/org/apache/tools/ant/PropertyHelper.java +++ b/src/main/org/apache/tools/ant/PropertyHelper.java @@ -213,8 +213,16 @@ public class PropertyHelper implements GetProperty { public String parsePropertyName( String s, ParsePosition pos, ParseNextProperty notUsed) { int index = pos.getIndex(); - if (s.indexOf("$$", index) == index) { - pos.setIndex(++index); + if (s.length() - index >= 2) { + /* check for $$; if found, advance by one-- + * this expander is at the bottom of the stack + * and will thus be the last consulted, + * so the next thing that ParseProperties will do + * is advance the parse position beyond the second $ + */ + if ('$' == s.charAt(index) && '$' == s.charAt(++index)) { + pos.setIndex(index); + } } return null; }