commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe Renon (JIRA)" <>
Subject [jira] [Created] (BEANUTILS-459) Adding and removing properties to LazyDynaClass is expensive
Date Fri, 07 Mar 2014 16:38:44 GMT
Philippe Renon created BEANUTILS-459:

             Summary: Adding and removing properties to LazyDynaClass is expensive
                 Key: BEANUTILS-459
             Project: Commons BeanUtils
          Issue Type: Improvement
          Components: DynaBean
    Affects Versions: 1.8.3
            Reporter: Philippe Renon

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) {


        // 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


    protected void setProperties(DynaProperty[] properties) { = properties;
        for (int i = 0; i < properties.length; i++) {
            propertiesMap.put(properties[i].getName(), properties[i]);


This message was sent by Atlassian JIRA

View raw message