satisfies? has very poor performance, and the way visit* works, it calls override? for each object it visits, incurring a pretty big overhead.
An easy alternative to using satisfies? is:
(defprotocol IOverride
"Mark object as preferring its custom IEdn behavior."
(-override? [this]))
(defn override?
[this]
(-override? this))
(extend-protocol IOverride
Object (-override? [_] false)
nil (-override? [_] false))
The problem with such change is it breaks current users, of which there are several
https://github.com/search?q=IOverride+fipp.ednize&type=code
This leaves four:
- Don't touch the old implementation, add a new code path (visit2?), and make the visit function a parameter which defaults to the original visit function. That way users can opt into the faster implementation, while the old implementation can undergo a deprecation process in the future
- Break, bump major version, try to make migration as painless as possible.
- Cache the results of calling
satisfies?. This has the downsides of being influenced by load order. Possible mitigation is attaching the cache to the visitor instead of making it global.
- Redesign. For example, abandon the override check and find a way to go directly through
IEdn (with another arity?) or another protocol
Any solution that finds a way to remove the call to satisfies? will make fipp way faster.
Happy to help with whatever solution you think will be correct, wdyt?
satisfies?has very poor performance, and the wayvisit*works, it callsoverride?for each object it visits, incurring a pretty big overhead.An easy alternative to using
satisfies?is:The problem with such change is it breaks current users, of which there are several
https://github.com/search?q=IOverride+fipp.ednize&type=code
This leaves four:
satisfies?. This has the downsides of being influenced by load order. Possible mitigation is attaching the cache to the visitor instead of making it global.IEdn(with another arity?) or another protocolAny solution that finds a way to remove the call to
satisfies?will make fipp way faster.Happy to help with whatever solution you think will be correct, wdyt?