diff options
author | Marius Volkhart <mariusvolkhart@apache.org> | 2021-03-01 00:04:51 +0000 |
---|---|---|
committer | Marius Volkhart <mariusvolkhart@apache.org> | 2021-03-01 00:04:51 +0000 |
commit | 402d0fc5e56349b3d6f447d56c8eef77a91b73ff (patch) | |
tree | e7b5e97819f1ad689f341ffc112af38616249c8c /src/java/org/apache/poi/ddf | |
parent | d1c9a07860e365db4e335d24ad67e87544bdcceb (diff) | |
download | poi-402d0fc5e56349b3d6f447d56c8eef77a91b73ff.tar.gz poi-402d0fc5e56349b3d6f447d56c8eef77a91b73ff.zip |
Review EscherContainerRecord#getChildRecords() call sites for unnecessary work
This started off as wanting to add the EscherContainerRecord#getChildCount() function in order to do an efficient check for how many children the container has. This was desirable in new code for editing HSSF pictures. The existing option of calling getChildRecords().size() was undesirable as this requires a list copy first.
In the process of finding call sites that would benefit from replacing getChildRecords().size(), I realized that several other patterns would benefit from eliminating a copy, such as iterating over the children in a for-each loop, and indexed access to specific children.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1887020 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/ddf')
-rw-r--r-- | src/java/org/apache/poi/ddf/EscherContainerRecord.java | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/java/org/apache/poi/ddf/EscherContainerRecord.java b/src/java/org/apache/poi/ddf/EscherContainerRecord.java index 474b24a436..bbe7efac65 100644 --- a/src/java/org/apache/poi/ddf/EscherContainerRecord.java +++ b/src/java/org/apache/poi/ddf/EscherContainerRecord.java @@ -158,6 +158,10 @@ public final class EscherContainerRecord extends EscherRecord implements Iterabl return new ArrayList<>(_childRecords); } + public int getChildCount() { + return _childRecords.size(); + } + /** * @return an iterator over the child records */ |