-
Notifications
You must be signed in to change notification settings - Fork 88
refactor(consumer)!: Optimize tree access and change handling #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I did a first pass and it looks good to me. I'll think a bit more about all the changes before approving though. |
|
Now I'm not so sure about some of these changes myself. In particular, I might undo the change to pass and return node IDs by reference. The optimizer can eliminate many copy operations anyway. |
c76f819 to
69ecbdc
Compare
|
I rolled back the change to pass node IDs by reference rather than value. I also decided to keep the existing |
11d5a22 to
5992d6b
Compare
|
@DataTriny Please let me know if you're still concerned about any of the changes on this PR. Some of the smaller optimizations in the Windows adapter might not have been the best use of my time, but I think the remaining API changes in the consumer crate are still good. |
DataTriny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good design improvements. Just a cosmetic remark, feel free to ignore it.
…`TreeReader` struct
…ference to the tree
…ad of one big pattern-matching function, so those functions can be separately inlined (or not)
563c863 to
521fb16
Compare
This PR has the following high-level design changes:
WeakNodefromaccesskit_consumer. I found that this approach forced AccessKit to do the full node lookup process whether or not it was necessary for a particular platform adapter method. Also, for some future uses ofaccesskit_consumer, such as an in-process self-voicing module, something likeWeakNodewon't be needed at all.accesskit_consumer, the methods to perform actions are now onTreerather thanNode. This change combined with the previous one means thatNodeno longer needs a reference (whether direct or indirect) back toTree.TreeReaderstruct.Nodeonly needs a reference totree::State, which is now exported asTreeState, andTree::readnow returns theRwLockread guard as an opaque object that dereferences toTreeState.Tree::update_and_process_changesnow takes an implementation of a trait with multiple functions, rather than a single closure. The functions in this trait correspond to the variants of the oldChangeenum. This way, the compiler can separately decide whether to inline each function at the place(s) where it's called, instead of having to work with one big closure that does pattern-matching.accesskit_consumer::Nodehas new methods for returning parent, child, and sibling IDs, without resolving them to full nodes. This is only possible when not checking the node's ignored status.FollowingSiblingsandPrecedingSiblingsiterator implementations; we can just use slices.There are also many changes to the Windows platform adapter to take advantage of these design changes, and some smaller optimizations. Some UIA method implementations no longer need to look up a full node. In a few cases, this PR reverses a previous decision to resolve the node even though we didn't need to, because I now think that the optimization benefit outweighs the theoretical risk of leaking implementation details about how we handle nodes that no longer exist.