Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 71327CEC4 for ; Fri, 7 Mar 2014 16:39:20 +0000 (UTC) Received: (qmail 62739 invoked by uid 500); 7 Mar 2014 16:38:50 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 62494 invoked by uid 500); 7 Mar 2014 16:38:47 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 62362 invoked by uid 99); 7 Mar 2014 16:38:44 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Mar 2014 16:38:44 +0000 Date: Fri, 7 Mar 2014 16:38:44 +0000 (UTC) From: "Philippe Renon (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (BEANUTILS-459) Adding and removing properties to LazyDynaClass is expensive MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 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) { // 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)