AX: Pre-size AXIsolatedObject::m_propertyMap to avoid unnecessary HashTable reallocations
<rdar://problem/103687278>
Created attachment 464196 [details] Patch
Comment on attachment 464196 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=464196&action=review > Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp:57 > + m_propertyMap.reserveInitialCapacity(126); Is there a way to calculate this number less manually
(In reply to chris fleizach from comment #3) > Comment on attachment 464196 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=464196&action=review > > > Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp:57 > > + m_propertyMap.reserveInitialCapacity(126); > > Is there a way to calculate this number less manually I don't think so. We could do: m_propertyMap.reserveInitialCapacity(static_cast<unsigned>(AXPropertyName::VisibleRows)); Where AXPropertyName::VisibleRows is the last member of the AXPropertyName enum class. But that would assume that every object has every property, which definitely isn't true, and would cause us to over-allocate the hashmap for every object.
> > Is there a way to calculate this number less manually > I don't think so. We could do: > > m_propertyMap.reserveInitialCapacity(static_cast<unsigned>(AXPropertyName:: > VisibleRows)); > > Where AXPropertyName::VisibleRows is the last member of the AXPropertyName > enum class. But that would assume that every object has every property, > which definitely isn't true, and would cause us to over-allocate the hashmap > for every object. Though we could probably do it if we had some structure that defined the properties for each type of object (i.e. something like WebAccessibilityObjectWrapperMac::accessibilityAttributeNames does), rather than the ad-hoc initialization we do now in AXIsolatedObject::initializeProperties. But sizing the map based on such a structure would be invalidated by sparse property storage, too, so probably not worth the work to do.
Committed 258328@main (98a28389be81): <https://commits.webkit.org/258328@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 464196 [details].