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

Henri Yandell updated LANG-340:
-------------------------------

    Fix Version/s: 3.0

Setting for investigation in 3.0 (though if anyone wants to dig into it, please 
feel free).

My suspicion is that a generic library has costs and if this is as centric to 
your application as it sounds then we're not going to be able to eke much out. 
However - who knows until someone looks :)

> 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.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to