[jbosscache-issues] [JBoss JIRA] Created: (JBCACHE-1537) Improve efficiency of Fqn.equals()

Brian Stansberry (JIRA) jira-events at lists.jboss.org
Thu Aug 20 18:53:23 EDT 2009


Improve efficiency of Fqn.equals()
----------------------------------

                 Key: JBCACHE-1537
                 URL: https://jira.jboss.org/jira/browse/JBCACHE-1537
             Project: JBoss Cache
          Issue Type: Task
      Security Level: Public (Everyone can see)
            Reporter: Brian Stansberry
            Assignee: Manik Surtani


Related to JBCACHE-1536.

In the RegionManager, Fqns are used a map keys. So equals/hashcode performance is critical. We should look at ways to improve. I don't see much in hashCode, but equals is pretty expensive.  The main computation is comparing the elements lists, which with both ArrayList and ImmutableListCopy (the expected types) is inherited from AbstractList and uses a listIterator.

A possible simple optimization is to iterate backwards through the lists.  The last element in the Fqn is much more likely to differ than the first.

Another is to not call hasNext()/hasPrevious() on both iterators. The lists are immutable and Fqn.equals has already established they have the same size. So one hasXXX is enough.

Shooting for bigger game is to replace the backing List with an array. Get rid of the iterator creation.  This should also speed Fqn creation, since all the vararg constructors naturally pass in an immutable array. Downside is some of the "sublist" logic that ArrayList and ImmutableListCopy have would need to be ported to Fqn itself, in order to support getParent() and getSubFqn().

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jbosscache-issues mailing list