Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 29859 invoked from network); 25 Feb 2010 19:42:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Feb 2010 19:42:51 -0000 Received: (qmail 83305 invoked by uid 500); 25 Feb 2010 19:42:50 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 83232 invoked by uid 500); 25 Feb 2010 19:42:50 -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 83224 invoked by uid 99); 25 Feb 2010 19:42:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Feb 2010 19:42:50 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Feb 2010 19:42:48 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id E3205234C48C for ; Thu, 25 Feb 2010 11:42:27 -0800 (PST) Message-ID: <671137726.533061267126947929.JavaMail.jira@brutus.apache.org> Date: Thu, 25 Feb 2010 19:42:27 +0000 (UTC) From: "Niall Pemberton (JIRA)" To: issues@commons.apache.org Subject: [jira] Updated: (LANG-500) ClassUtils.getAllInterfaces(...) could be more efficient In-Reply-To: <2013683203.1240976130476.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LANG-500?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Niall Pemberton updated LANG-500: --------------------------------- Affects Version/s: (was: 3.1) Fix Version/s: (was: 3.0) 2.5 > ClassUtils.getAllInterfaces(...) could be more efficient > -------------------------------------------------------- > > Key: LANG-500 > URL: https://issues.apache.org/jira/browse/LANG-500 > Project: Commons Lang > Issue Type: Improvement > Components: lang.* > Reporter: Pino Silvaggio > Priority: Trivial > Fix For: 2.5 > > Attachments: LANG-500.patch, patch-ClassUtils-01.txt, patch-ClassUtils-02.txt > > > This could seem like a very minor thing but why not improve > the code once in a while... > Something like this could replace the current inefficient code: > {code} > public static List> getAllInterfaces(Class clazz) > { > if (clazz == null) > { > return null; > } > HashSet> interfacesSet = new HashSet>(); > LinkedList> interfacesList = new LinkedList>(); > getAllInterfaces(clazz, interfacesSet, interfacesList); > return interfacesList; > } > private static void getAllInterfaces( > Class clazz, > HashSet> interfacesSet, List> interfacesList) > { > while (clazz != null) > { > Class[] interfaces = clazz.getInterfaces(); > for (Class i : interfaces) > { > if (!interfacesSet.add(i)) > { > interfacesList.add(i); > getAllInterfaces(i, interfacesSet, interfacesList); > } > } > clazz = clazz.getSuperclass(); > } > } > {code} -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.