Why do you use @generated functions?
This line confuses me, why do you need the && part if you have it covered by the else clause?
EDIT: just deleted my proposal for a faster version , If you remove && x == y
your code works as you intended
2nd Edit: I finally understand @generated functions
if you follow my first suggestion you might compare too different types as equal if they have the same number of fields
with the same name.
This solves the issue:
@generated function ≂(x, y)
if !isempty(fieldnames(x)) && (x.name == y.name)
mapreduce(n -> :(x.$n == y.$n), (a,b)->:($a && $b), fieldnames(x))
else
:(x == y)
end
end
in a generated function anything that is not quoted is just its inferred datatype, got it now.