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 9A84FD892 for ; Tue, 9 Oct 2012 01:56:03 +0000 (UTC) Received: (qmail 91331 invoked by uid 500); 9 Oct 2012 01:56:03 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 91255 invoked by uid 500); 9 Oct 2012 01:56:03 -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 91242 invoked by uid 99); 9 Oct 2012 01:56:03 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Oct 2012 01:56:03 +0000 Date: Tue, 9 Oct 2012 01:56:03 +0000 (UTC) From: "Matt Benson (JIRA)" To: issues@commons.apache.org Message-ID: <707652544.12314.1349747763101.JavaMail.jiratomcat@arcas> In-Reply-To: <52920154.141491.1348873627529.JavaMail.jiratomcat@arcas> Subject: [jira] [Commented] (LANG-839) ArrayUtils removeElements methods use unnecessary HashSet MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LANG-839?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13472056#comment-13472056 ] Matt Benson commented on LANG-839: ---------------------------------- Nice! > ArrayUtils removeElements methods use unnecessary HashSet > --------------------------------------------------------- > > Key: LANG-839 > URL: https://issues.apache.org/jira/browse/LANG-839 > Project: Commons Lang > Issue Type: Improvement > Components: lang.* > Affects Versions: 3.1 > Reporter: Sebb > Priority: Minor > Fix For: 3.2 > > Attachments: LANG-839.patch > > > The removeElements() methods use a HashSet to collect the indexes that need removing. > This requires creating Integer objects for each index, and the HashSet then has to be converted into an int[] array. > It would be more efficient to store the entries in an actual int[] array. > The maximum size of this is the length of the values array (or the length of the input array if that is shorter). > The array must be truncated before calling the private removeAll() method; this can be done with Arrays.copyOf(x[], length). > However, if the arrays are very large, and most of the values do not appear in the input, this might result in using more memory than the HashSet implementation. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira