fun node_at(k: K): nullable N
do
# cache: `is` is used instead of `==` because it is a faster filter (even if not exact)
- if k is _last_accessed_key then return _last_accessed_node
+ if k.is_same_instance(_last_accessed_key) then return _last_accessed_node
var res = node_at_idx(index_at(k), k)
_last_accessed_key = k
var c = _array[i]
while c != null do
var ck = c._key
- if ck is k or ck == k then # prefilter with `is` because the compiler is not smart enought yet
+ if ck.is_same_instance(k) or ck == k then # FIXME prefilter because the compiler is not smart enought yet
break
end
c = c._next_in_bucklet
# Unless specific code, you should not use this method.
fun is_same_type(other: Object): Bool is intern
+ # Return true if `self` and `other` are the same instance.
+ # Unless specific code, you should use `==` instead.
+ fun is_same_instance(other: nullable Object): Bool do return self is other #is intern
+
# Have `self` and `other` the same value?
##
# The exact meaning of "same value" is let to the subclasses.
- # Implicitly, the default implementation, is `is`
- fun ==(other: nullable Object): Bool do return self is other
+ # Implicitly, the default implementation, is `is_same_instance`
+ fun ==(other: nullable Object): Bool do return self.is_same_instance(other)
# Have `self` and `other` different values?
##