Bug 54305

Summary: more efficient method call in FileUtils.isContextRelativePath
Product: Ant Reporter: Adrian Nistor <nistor1>
Component: CoreAssignee: Ant Notifications List <notifications>
Status: RESOLVED FIXED    
Severity: normal CC: jglick, nistor1
Priority: P2 Keywords: PatchAvailable
Version: 1.9.1   
Target Milestone: 1.9.4   
Hardware: PC   
OS: Linux   
Attachments: patch

Description Adrian Nistor 2012-12-14 23:35:07 UTC
Created attachment 29767 [details]
patch

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

In method "FileUtils.isContextRelativePath", the call
"filename.indexOf(':') == 1" should be "filename.charAt(1) == ':'"
(the first character is a letter as checked by "Character.isLetter(c)"
earlier in the boolean expression).  In the entire method, "charAt" is
already used 3 different times to check the values of characters 0, 1,
and 2 (while "indexOf" just once, in the instance described above).
These existing 3 calls to "charAt" make the string pattern being
checked for more explicit.  Also, "charAt" is more efficient than
"indexOf", because "charAt" reads only a single character at a given
position, while "indexOf" searches until the first occurrence.
Comment 1 Stefan Bodewig 2014-01-02 14:40:57 UTC
svn revision 1554813