Bug 49432

Summary: CommentsTable.getCTComment() has poor performance
Product: POI Reporter: Alex <alexkra>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.6-FINAL   
Target Milestone: ---   
Hardware: All   
OS: All   

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.