Author: mariusvolkhart
Date: Wed Mar 10 21:42:19 2021
New Revision: 1887453

URL: http://svn.apache.org/viewvc?rev=1887453&view=rev
Log:
Streamline HPSF CustomProperties collection retrieval

Reduce the number of map lookups necessary to compute the return values for 
methods that return collections of property details. Since we maintain parity 
between the `props` and `dictionary` contents, when retrieving property 
details, we can reference the `props` directly and avoid the `dictionary` 
indirection.

Modified:
    poi/trunk/src/java/org/apache/poi/hpsf/CustomProperties.java

Modified: poi/trunk/src/java/org/apache/poi/hpsf/CustomProperties.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hpsf/CustomProperties.java?rev=1887453&r1=1887452&r2=1887453&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hpsf/CustomProperties.java (original)
+++ poi/trunk/src/java/org/apache/poi/hpsf/CustomProperties.java Wed Mar 10 
21:42:19 2021
@@ -219,9 +219,7 @@ public class CustomProperties implements
      */
     public List<CustomProperty> properties() {
         List<CustomProperty> list = new ArrayList<>(props.size());
-        for (Long l : dictionary.keySet()) {
-            list.add(props.get(l));
-        }
+        list.addAll(props.values());
         return Collections.unmodifiableList(list);
     }
     
@@ -231,8 +229,8 @@ public class CustomProperties implements
     @Override
     public Collection<Object> values() {
         List<Object> list = new ArrayList<>(props.size());
-        for (Long l : dictionary.keySet()) {
-            list.add(props.get(l).getValue());
+        for (CustomProperty property : props.values()) {
+            list.add(property.getValue());
         }
         return Collections.unmodifiableCollection(list);
     }
@@ -240,8 +238,8 @@ public class CustomProperties implements
     @Override
     public Set<Entry<String, Object>> entrySet() {
         Map<String,Object> set = new LinkedHashMap<>(props.size());
-        for (Entry<Long,String> se : dictionary.entrySet()) {
-            set.put(se.getValue(), props.get(se.getKey()).getValue());
+        for (CustomProperty property : props.values()) {
+            set.put(property.getName(), property.getValue());
         }
         return Collections.unmodifiableSet(set.entrySet());
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to