unitsofmeasurement / indriya

JSR 385 - Reference Implementation
Other
119 stars 42 forks source link

(#393) DefaultNumberSystem: slight performance improvements #405

Closed andi-huber closed 11 months ago

andi-huber commented 11 months ago

Improvements:


This change is Reviewable

keilw commented 11 months ago

I was away for a few days, but will have a look tomorrow.

andi-huber commented 11 months ago

Found a view more optimization candidates today. Implemented these. Now PR is ready for review.

andi-huber commented 11 months ago

Why are some methods like

        @Override boolean isZero(Number number) {
                return ((AtomicInteger) number).intValue() == 0;
            }
        },

casting directly to e.g. AtomicInteger while other methods check for instanceof before?

Hi Werner. If we do the isZero(Number number) checks within the (private) enum NumberType, an instanceof check is no longer required, because we already know what type the number parameter has. This is implicit knowledge, which I did not have a good idea how to communicate better within the code or comments.