Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.8.3
-
None
-
None
Description
Adding and removing properties from a LazyDynaClass involves array copying and map rebuilding and gets quite expensive if done often.
Main issue is that it generates quite a lot of garbage.
protected void add(DynaProperty property) { <snip> // Create a new property array with the specified property DynaProperty[] oldProperties = getDynaProperties(); DynaProperty[] newProperties = new DynaProperty[oldProperties.length+1]; System.arraycopy(oldProperties, 0, newProperties, 0, oldProperties.length); newProperties[oldProperties.length] = property; // Update the properties setProperties(newProperties); }
protected void setProperties(DynaProperty[] properties) { this.properties = properties; propertiesMap.clear(); for (int i = 0; i < properties.length; i++) { propertiesMap.put(properties[i].getName(), properties[i]); } }