Optimization in KDE Base
Yet another optimization/improvement.
Instead of using a filter for the types which in some cases does not
return the correct results (not sure why though) we now check the types
after querying candidates. This is fast and should work nicely in most
cases. There is a theoretical possibility that we might miss candidates
since we are using a limit of 100 on the main query. But this has a
rather small probability and the performance is worth it.