ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 54302] New: more efficient (and shorter) method call in FTPTaskMirrorImpl.FTPDirectoryScanner.AntFTPFile.getFastRelativePath
Date Fri, 14 Dec 2012 21:10:45 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=54302

            Bug ID: 54302
           Summary: more efficient (and shorter) method call in
                    FTPTaskMirrorImpl.FTPDirectoryScanner.AntFTPFile.getFa
                    stRelativePath
           Product: Ant
           Version: 1.8.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
          Assignee: notifications@ant.apache.org
          Reporter: nistor1@illinois.edu
    Classification: Unclassified

Created attachment 29763
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=29763&action=edit
patch

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

In method
"FTPTaskMirrorImpl.FTPDirectoryScanner.AntFTPFile.getFastRelativePath",
the call "absPath.indexOf(rootPath + task.getSeparator()) == 0" should
be "absPath.startsWith(rootPath + task.getSeparator())".  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 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.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Mime
View raw message