Bug 48755

Summary: Zip task does O(n) lookup in hashtable
Product: Ant Reporter: Marc Bevand <m.bevand>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 1.8.0   
Target Milestone: 1.8.1   
Hardware: All   
OS: All   
Attachments: Fixes the Zip task performance bug

Description Marc Bevand 2010-02-17 03:28:14 UTC
Created attachment 25004 [details]
Fixes the Zip task performance bug

The ant zip task does an O(n) instead of O(1) lookup in a Hashtable when adding files to the archive. The attached patch fixes this embarassing performance bug by calling containsKey() instead of contains(). It applies cleanly to Ant 1.8.0.

I measured a 3x performance improvement with the jar task (based on the zip task) when creating a jar from a directory containing 50 thousand files on my system:

      <jar destfile="foo.jar" basedir="dir-with-50k-files"/>

Before: 103 sec
After: 32 sec
Comment 1 Stefan Bodewig 2010-02-17 05:10:36 UTC
Ooops.

fixed with svn revision 910825

thanks!
Comment 2 Marc Bevand 2010-02-17 07:01:45 UTC
Thanks.

PS: you made a typo in my last name in the commit message (Bevand, not Beyand). Oh well :-)
Comment 3 Stefan Bodewig 2010-02-17 08:56:00 UTC
sorry about the spelling error, fixed now.

an underlined v looks a lot like a y in the font I use in Firefox.