Bug 48755 - Zip task does O(n) lookup in hashtable
Summary: Zip task does O(n) lookup in hashtable
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.8.0
Hardware: All All
: P2 normal (vote)
Target Milestone: 1.8.1
Assignee: Ant Notifications List
Depends on:
Reported: 2010-02-17 03:28 UTC by Marc Bevand
Modified: 2010-02-17 08:56 UTC (History)
0 users

Fixes the Zip task performance bug (514 bytes, patch)
2010-02-17 03:28 UTC, Marc Bevand
Details | Diff

Note You need to log in before you can comment on or make changes to this 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

fixed with svn revision 910825

Comment 2 Marc Bevand 2010-02-17 07:01:45 UTC

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.