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 6F6ABC8FE for ; Mon, 7 May 2012 11:11:01 +0000 (UTC) Received: (qmail 33656 invoked by uid 500); 7 May 2012 11:11:01 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 33444 invoked by uid 500); 7 May 2012 11:11:01 -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 33389 invoked by uid 99); 7 May 2012 11:11:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 May 2012 11:11:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 May 2012 11:10:14 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id D713A437C1C for ; Mon, 7 May 2012 11:09:54 +0000 (UTC) Date: Mon, 7 May 2012 11:09:54 +0000 (UTC) From: "Gilles (JIRA)" To: issues@commons.apache.org Message-ID: <30914680.33861.1336388994882.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1629638549.26933.1336138368267.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (MATH-786) "hashCode" in "Pair" class 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/MATH-786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13269529#comment-13269529 ] Gilles commented on MATH-786: ----------------------------- bq. Do you have a use case at hand that requires this change? It's an optimization suggested by a developer who works with maps. I have no idea how much gain it provides; but it seems that for an application that calls "hashCode" a lot, that might be useful... I don't understand why you call it "premature" optimization. If the Javadoc states that the correct behaviour is up to the user, I don't see any real problem; we have other cases where a flag indicates that a reference is stored, and if the user does something he shouldn't, the same "problems" will be created. What I propose seems the perfect compromise between always assuming immutable (the two Seb's opinion) and never optimize "hashCode" (your opinion). The default being no optimization so that users are not bitten by surprise. Shall I apply the change? > "hashCode" in "Pair" class > -------------------------- > > Key: MATH-786 > URL: https://issues.apache.org/jira/browse/MATH-786 > Project: Commons Math > Issue Type: Improvement > Affects Versions: 3.0 > Reporter: Gilles > Assignee: Gilles > Priority: Trivial > Fix For: 3.1 > > > Since "Pair" is supposed to be an immutable class, couldn't we cache the "hashCode" value at construction? That would supposedly make it more efficient when used in maps. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira