Optimize accessing fields through memoization cache #6
Labels
No labels
bug
duplicate
enhancement/documentation
enhancement/feature
enhancement/organization
question
rejected
upstream
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
UserCurt/mpath#6
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
An mpath expression or expression array can have repeated elements. The current implementation will try to access the field multiple times, which can be slow particularly with some custom class implementations. Implementation of memorization can improve this by reducing the number of times mpath needs to access fields. This is most appropriate in
mpath.get, but it is also applicable inmpath.resolveas sometimes it needs to get values to resolve the mpath. Note that whengetcallsresolve,resolveshould share the memoization object for further efficiency gains.A few options for passing the cache between
resolveandget:mpath.resolvefor the memoization cachempath.resolvereturnmpath.ConcretePointerwhich inheritsmpath.Pointerwith an additional property for the cache.Within
get, there may need to be a method that is able to identify common elements within sub-mpaths.There may be some edge case considerations when it comes to chunked atomic index operations. Consider
mpath.resolve(S, ["/a/b<1>/c/x"; "/a/b<1>/c/y"]). Here,/c/xis a single indexOp and so is/c/y.Having resolve return
mpath.ConcretePointerrather thanmpath.Pointercould help withmpath.exist(issue #8) not having to do extra work after runningmpath.resolveas it could also store whether the path exists (in a specific struct). It may also be helpful for recursive dot operation (issue #17) in ways that are unclear at this time.Commit
7ff390fintegratedgetwith the shared traversal engine, removing the second data fetch which was main issue brought forward by this issue. So this source is considered obsolete.Though a similar idea persists in issue #47 tracking related write-back for mutation operations.