[ 
https://issues.apache.org/jira/browse/CASSANDRA-8988?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14370394#comment-14370394
 ] 

Benedict commented on CASSANDRA-8988:
-------------------------------------

There are a few possibilities for implementing the find method efficiently that 
I wasn't planning to explore just yet, but since you've asked me to justify 
myself I've gone ahead and uploaded what I think is probably about as efficient 
as we can manage (a very minor tweak in fact). 

To justify the rationale of using the switch statement: If I were expecting a 
compiler to optimise well, I would put money on the switch being faster than a 
field access (which any enum method would amount to after inlining). This is 
because, in principle, the location of the enum itself can be substituted in 
without having to suffer the indirection costs of field access, and there is 
only one conditional expression to evaluate when the switch statement has only 
two possible outcomes. A single branch on a value is typically very fast.

Since an improved implementation above either approach was really trivial, 
though, let's go with that.

> Optimise IntervalTree
> ---------------------
>
>                 Key: CASSANDRA-8988
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-8988
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Benedict
>            Assignee: Benedict
>            Priority: Minor
>             Fix For: 3.0
>
>         Attachments: 8988.txt
>
>
> We perform a lot of unnecessary comparisons in 
> IntervalTree.IntervalNode.searchInternal.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to