Avoid equals for object comparison with the missing default keyword last

Description

The problem is in the code that does in evict for LRU/LU/FIFO caches:

(let [v (get cache key :miss)]
if (= v :miss) ....))

In the case that v exists and is a java object, the = op will result in a call to v.equals for that specific class. That method is arbitrary and might be expensive. An example case is Matrix4d from vecmath https://github.com/hharrison/vecmath/blob/master/src/javax/vecmath/Matrix4d.java that would throw and catch exceptions.

Proposal: replace check with (contains? cache key) where possible and where not, reverse the args so it is (= :miss v).

Environment

None

Activity

Show:
Sean Corfield
March 1, 2018, 4:50 AM

Closing out all resolved issues as of 0.6.5 in order to track the next release.

Fogus
March 25, 2016, 8:27 PM

Thank you.

Carin Meier
March 25, 2016, 8:04 PM

Fixed typo with position of =

Completed

Assignee

Fogus

Reporter

Carin Meier

Labels

None

Approval

Accepted

Patch

Code and Test

Priority

Major