[
https://jira.jboss.org/jira/browse/JBCACHE-1537?page=com.atlassian.jira.p...
]
Manik Surtani commented on JBCACHE-1537:
----------------------------------------
This allows a number of other enhancements internally when constructing or scanning Fqn
for elements, including the better equals() comparison detailed above.
Back Fqn by an immutable array rather than a List for efficiency
----------------------------------------------------------------
Key: JBCACHE-1537
URL:
https://jira.jboss.org/jira/browse/JBCACHE-1537
Project: JBoss Cache
Issue Type: Task
Security Level: Public(Everyone can see)
Affects Versions: 3.2.0.GA
Reporter: Brian Stansberry
Assignee: Manik Surtani
Fix For: 3.2.1.GA
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