opensubscriber
   Find in this group all groups
 
Unknown more information…

i : issues@commons.apache.org 7 September 2009 • 7:35AM -0400

[jira] Closed: (LANG-340) performance problem with EqualsBuilder.append()
by Henri Yandell (JIRA)

REPLY TO AUTHOR
 
REPLY TO GROUP





     [ https://issues.apache.org/jira/browse/LANG-340?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell closed LANG-340.
------------------------------

    Resolution: Won't Fix

No work has happened, so closing as a won't fix under the assumption that this is the price of a generic library.

> performance problem with EqualsBuilder.append()
> -----------------------------------------------
>
>                 Key: LANG-340
>                 URL: https://issues.apache.org/jira/browse/LANG-340
>             Project: Commons Lang
>          Issue Type: Improvement
>    Affects Versions: 2.3
>            Reporter: Ramil Israfilov
>             Fix For: 3.0
>
>
> We are using EqualsBuilder for construction of equals() method in our javabeans.
> For example we have a class:
> public class SimpleRecord{
> String name;
> String label;
> ...
>     public boolean equals(Object object) {
>         return new EqualsBuilder().append(this.label, rhs.label).append(
>                 this.getName(), rhs.getName()).isEquals();
>     }
> So far so good.
> But one of our applications uses extensively Stack to push/pop SimpleRecord bean. And it was working very slow.
> After profiling of application we saw that most of the time JVM spent in equals() method of SimpleRecord. (it is called during peek() which is calling remove() from Stack)
> If we replace EqualsBuilder by following code our application worked 3 times faster ! Could you make some optimizations ?
>     if (!(object instanceof SimpleRecord)) {
>             return false;
>         }
>         SimpleRecord rhs = (SimpleRecord) object;
>         if (this.getName() == null && rhs.getName() != null) {
>         return false;
>         } else
>         if (rhs.getName() == null && this.getName() != null) {
>         return false;
>         } else
>         if (this.label == null && rhs.label != null) {
>         return false;
>         } else
>         if (rhs.label == null && this.label != null) {
>         return false;
>         } else
>         if (this.label == null && rhs.label == null) {
>         return this.getName().equals(rhs.getName());
>         } else
>        
>         return this.getName().equals(rhs.getName()) && this.label.equals(rhs.label);

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

opensubscriber is not affiliated with the authors of this message nor responsible for its content.