commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe Renon (JIRA)" <j...@apache.org>
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
                 URL: https://issues.apache.org/jira/browse/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.

{code}
    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);

    }
{code}

{code}
    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]);
        }

    }
{code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message