Bug 54303 - more efficient (and shorter) method calls in XmlPropertyTest.ensureProperties
Summary: more efficient (and shorter) method calls in XmlPropertyTest.ensureProperties
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.9.1
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: 1.9.4
Assignee: Ant Notifications List
Keywords: PatchAvailable
Depends on:
Reported: 2012-12-14 21:21 UTC by Adrian Nistor
Modified: 2014-01-02 14:40 UTC (History)
2 users (show)

firstCall.diff (712 bytes, patch)
2012-12-14 21:21 UTC, Adrian Nistor
Details | Diff
secondCall.diff (694 bytes, patch)
2012-12-14 21:22 UTC, Adrian Nistor
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Nistor 2012-12-14 21:21:52 UTC
Created attachment 29764 [details]

The problem appears in version 1.8.4 and in revision 1421898.  I
attached a one-line patch (firstCall.diff) that fixes it.

In method "XmlPropertyTest.ensureProperties", the call
"propertyValue.indexOf("ID.") == 0" should be
"propertyValue.startsWith("ID.")".  The intent of the call is more
explicit with "startsWith" than with "indexOf(..) == 0".  "startsWith"
is also more efficient than "indexOf", because "startsWith" tries to
match only the start of the string, while "indexOf" searches until the
first occurrence.

There is a similar second call to "propertyValue.indexOf("FILE.") == 0".  
I attached a second patch (secondCall.diff) for it.

There are many calls to "String.startsWith" in Ant (just like in the
proposed patch), for example, in methods "AntlibDefinition.setURI",
"AntClassLoader.isParentFirst", "ComponentHelper.checkNamespace",
"Execute.getVMSLogicals", "ExecTask.isPath", "Jar.writeIndexLikeList",
"Definer.makeResourceFromURI", "PathTokenizer.nextToken", etc.
Comment 1 Adrian Nistor 2012-12-14 21:22:18 UTC
Created attachment 29765 [details]
Comment 2 Stefan Bodewig 2014-01-02 14:40:27 UTC
svn revision 1554813