Bug 49432 - CommentsTable.getCTComment() has poor performance
Summary: CommentsTable.getCTComment() has poor performance
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.6-FINAL
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2010-06-13 08:32 UTC by Alex
Modified: 2010-06-14 11:44 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Alex 2010-06-13 08:32:02 UTC
CommentsTable.getCTComment() always goes over all comments. Run time is O(n^2).
In large Excel file when checking if cell has warning a total time that spent in this method can take many minutes.
By keeping the table in Map<String, CTComment> where key is comment.getRef() the run time imporved dramatically.
Also in XSSFSheet.read() method inside condition "if(p instanceof CommentsTable)" there is no "break" which should stop unnecessary processing.
Comment 1 Nick Burch 2010-06-14 11:44:34 UTC
We can't simply keep a map, we also need to take steps to keep it in sync as the comment references are updated, which means rippling up to the XSSFComment level

I've implemented lazy caching in r954521, which should hopefully sort it for you.