core.cache

Avoid equals for object comparison with the missing default keyword last

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Accepted

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).

Activity

Hide
Carin Meier added a comment -

Fixed typo with position of =

Show
Carin Meier added a comment - Fixed typo with position of =
Hide
Fogus added a comment -

Thank you.

Show
Fogus added a comment - Thank you.
Hide
Sean Corfield added a comment -

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

Show
Sean Corfield added a comment - Closing out all resolved issues as of 0.6.5 in order to track the next release.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: