Make `satisfies?` as fast as a protocol method call
Key details
Description
Currently `satisfies?` doesn't use the same impl cache used by protocol methods, making it too slow for real world usage.
With:
Before patch:
Cause: `satisfies?` calls `find-protocol-impl` to see whether an object implements a protocol, which checks for whether x is an instance of the protocol interface or whether x's class is one of the protocol implementations (or if its in an inheritance chain that would make this true). This check is fairly expensive and not cached.
Proposed: Extend the protocol's method impl cache to also handle (and cache) instance checks (including negative results).
Currently `satisfies?` doesn't use the same impl cache used by protocol methods, making it too slow for real world usage.
With:
Before patch:
Cause: `satisfies?` calls `find-protocol-impl` to see whether an object implements a protocol, which checks for whether x is an instance of the protocol interface or whether x's class is one of the protocol implementations (or if its in an inheritance chain that would make this true). This check is fairly expensive and not cached.
Proposed: Extend the protocol's method impl cache to also handle (and cache) instance checks (including negative results).
After patch:
Patch: CLJ-1814-v7.patch (depends on https://clojure.atlassian.net/browse/CLJ-2426#icft=CLJ-2426)