mirror of https://github.com/apache/poi.git
[github-735] POIFS: optimise occupied size calc. Thanks to Emmanuel Bourg. This closes #735
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1922232 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1700967d17
commit
c57f7a3b0e
|
@ -266,10 +266,9 @@ public class POIFSMiniStore extends BlockStore {
|
|||
int entriesPerBlock = _filesystem.getBigBlockSizeDetails().getBATEntriesPerBlock();
|
||||
for (int sbatIndex = _sbat_blocks.size() - 1; sbatIndex >= 0; sbatIndex--) {
|
||||
BATBlock sbat = _sbat_blocks.get(sbatIndex);
|
||||
for (int miniBlockIndex = entriesPerBlock - 1; miniBlockIndex >= 0; miniBlockIndex--) {
|
||||
if (sbat.getValueAt(miniBlockIndex) != POIFSConstants.UNUSED_BLOCK) {
|
||||
return (sbatIndex * entriesPerBlock) + miniBlockIndex + 1;
|
||||
}
|
||||
int occupiedSize = sbat.getOccupiedSize();
|
||||
if (occupiedSize > 0) {
|
||||
return (sbatIndex * entriesPerBlock) + occupiedSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -202,15 +202,12 @@ public final class BATBlock implements BlockWritable {
|
|||
* @since POI 5.0.0
|
||||
*/
|
||||
public int getOccupiedSize() {
|
||||
int usedSectors = _values.length;
|
||||
for (int k = _values.length - 1; k >= 0; k--) {
|
||||
if(_values[k] == POIFSConstants.UNUSED_BLOCK) {
|
||||
usedSectors--;
|
||||
} else {
|
||||
break;
|
||||
if (_values[k] != POIFSConstants.UNUSED_BLOCK) {
|
||||
return k + 1;
|
||||
}
|
||||
}
|
||||
return usedSectors;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getValueAt(int relativeOffset) {
|
||||
|
|
Loading…
Reference in New Issue