mirror of https://github.com/apache/poi.git
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. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1887453 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
74b4a460b2
commit
6a967ae622
|
@ -219,9 +219,7 @@ public class CustomProperties implements Map<String,Object> {
|
||||||
*/
|
*/
|
||||||
public List<CustomProperty> properties() {
|
public List<CustomProperty> properties() {
|
||||||
List<CustomProperty> list = new ArrayList<>(props.size());
|
List<CustomProperty> list = new ArrayList<>(props.size());
|
||||||
for (Long l : dictionary.keySet()) {
|
list.addAll(props.values());
|
||||||
list.add(props.get(l));
|
|
||||||
}
|
|
||||||
return Collections.unmodifiableList(list);
|
return Collections.unmodifiableList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,8 +229,8 @@ public class CustomProperties implements Map<String,Object> {
|
||||||
@Override
|
@Override
|
||||||
public Collection<Object> values() {
|
public Collection<Object> values() {
|
||||||
List<Object> list = new ArrayList<>(props.size());
|
List<Object> list = new ArrayList<>(props.size());
|
||||||
for (Long l : dictionary.keySet()) {
|
for (CustomProperty property : props.values()) {
|
||||||
list.add(props.get(l).getValue());
|
list.add(property.getValue());
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableCollection(list);
|
return Collections.unmodifiableCollection(list);
|
||||||
}
|
}
|
||||||
|
@ -240,8 +238,8 @@ public class CustomProperties implements Map<String,Object> {
|
||||||
@Override
|
@Override
|
||||||
public Set<Entry<String, Object>> entrySet() {
|
public Set<Entry<String, Object>> entrySet() {
|
||||||
Map<String,Object> set = new LinkedHashMap<>(props.size());
|
Map<String,Object> set = new LinkedHashMap<>(props.size());
|
||||||
for (Entry<Long,String> se : dictionary.entrySet()) {
|
for (CustomProperty property : props.values()) {
|
||||||
set.put(se.getValue(), props.get(se.getKey()).getValue());
|
set.put(property.getName(), property.getValue());
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableSet(set.entrySet());
|
return Collections.unmodifiableSet(set.entrySet());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue