Check if two sets have a non-empty intersection
The overhead you are seeing is likely due to function call overhead: op_u
is not being inlined.
This version inlines correctly and has the same performance as intersects
:
julia> function intersects2(u::DataStructures.IntSet, v::DataStructures.IntSet)
op_u(x) = u.inverse ? ~x : x
op_v(x) = v.inverse ? ~x : x
ch_u, ch_v = u.bits.chunks, v.bits.chunks
for i in 1:length(ch_u)
if op_u(ch_u[i]) & op_v(ch_v[i]) > 0
return true
end
end
false
end