Closed domenic closed 2 months ago
/agenda
I think the intent WAS for this to be an optimization. It's worth discussing with the larger group, so queuing this topic up for a future call.
After discussion on today's call it doesn't appear that implementations are currently attempting to re-use the returned array, so any potential optimizations this might have allowed aren't being actively pursued. As a result it seems fine to transition this to a regular sequence
and remove the distinction of being the only API on the Web Platform that does this. 😄
I'll make the spec change soon.
The spec has two methods,
getHitTestResults()
andgetHitTestResultsForTransientInput()
, which returnFrozenArray<>
s.Methods that return frozen arrays is unusual. (These are the only two such methods on the web platform, actually.) In general we do not want to make it harder for web developers to reuse arrays that we give them.
In theory, this might be a performance optimization, if these methods are called frequently and there is often a cache hit. Is that the case? I kind of doubt it, because the spec doesn't do any work to actually freeze the arrays, and just says "mapping from XRHitTestSource to an array of XRHitTestResults" without mentioning the frozenness.
If this is not necessary for a performance optimization, then it would be best to move to
sequence<>
s. That would help fix https://github.com/whatwg/webidl/issues/1399.