cats icon indicating copy to clipboard operation
cats copied to clipboard

[Perf] `Set.contains(value)` vs `alleyCatsSetTraverse.contains_(value)`

Open ronanM opened this issue 3 years ago • 3 comments

  • Set.contains(value)is O(1).
  • alleycats.std.SetInstances.alleyCatsSetTraverse.contains_(value) is in worst case O(n).

ronanM avatar Jan 10 '22 12:01 ronanM

They may have different behaviors :

  • Set.contains() use hashCode().
  • contains_() use Eq.eqv().

Optimization may be impossible ?

ronanM avatar Jan 10 '22 16:01 ronanM

Ah, good point. Yeah, this probably can't be fixed.

armanbilge avatar Jan 10 '22 16:01 armanbilge

A warning in the ScalaDoc may be useful for some FoldableOps functions ?

ronanM avatar Jan 10 '22 16:01 ronanM