Bug 1901676: Set lastParent and lastParentID in DocAccessibleParent::RecvShowEvent. r=eeejay

In bug 1779578, I changed the way a11y trees are serialised such that the parent id is included for each Accessible.
When de-serialising in DocAccessibleParent::RecvShowEvent, in order to avoid a theoretical performance regression caused by repeatedly looking up the same parent, I added an optimisation to use the last parent if it is the same as the current parent.
Unfortunately, it seems I never actually set the lastParent and lastParentID variables, so this optimisation was a no-op!

This is a micro-optimisation: it doesn't seem to make any observable difference.
However, it seems silly to have effectively dead code and it's a very straightforward fix.

Differential Revision: https://phabricator.services.mozilla.com/D213177
This commit is contained in:
James Teh 2024-06-12 00:56:29 +00:00
Родитель ff11598bbd
Коммит 808f8aaefd
1 изменённых файлов: 4 добавлений и 0 удалений

Просмотреть файл

@ -96,6 +96,8 @@ mozilla::ipc::IPCResult DocAccessibleParent::RecvShowEvent(
RemoteAccessible* lastParent = this;
uint64_t lastParentID = 0;
for (const auto& accData : aNewTree) {
// Avoid repeated hash lookups when there are multiple children of the same
// parent.
RemoteAccessible* parent = accData.ParentID() == lastParentID
? lastParent
: GetAccessible(accData.ParentID());
@ -109,6 +111,8 @@ mozilla::ipc::IPCResult DocAccessibleParent::RecvShowEvent(
return IPC_OK();
#endif
}
lastParent = parent;
lastParentID = accData.ParentID();
uint32_t childIdx = accData.IndexInParent();
if (childIdx > parent->ChildCount()) {