Closed vrurg closed 1 year ago
With these changes I managed to cover 100% of boxing in my code with cache. The stats, the way I posted them in #94, got count 1 for each unique key! Consequently, both a local test and the real tool working on a real file are ~3 times faster!
Downsides: I'm not as confident with this PR as I wish it to be. The overall point is to first get a user class for a raw node and then box through the class. Unfortunately, I have some doubts about applicability of this approach to LibXML::Node::List
and ::Set
. Moreover, ::Set
has an issue marked as TODO
for now.
Otherwise it seems that implementing caching would be less painful than I anticipated. The plan is to:
$!use-cache
or $!caching
on LibXML::Config
. R/O for now.maybe-cached
on the config. The method would try to use cached entries if $!use-cache
is true. Otherwise it would dispatch over a raw node by mapping it into a user class (class-from
but done using config-local structure, thus not paying the price of extra method call) and boxing if necessary.maybe-cached
would use callbacks to create new objects, if such callbacks are provided. Otherwise it would use box
on the resolved user class.Some minor details are skipped, they may depend on the outcomes of the implementation itself.
Give out more control to user-specified classes by boxing with
class-from
-provided classes.