Skip to content
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

Use of FrozenArray<>s for return types of methods is probably unnecessary #117

Closed
Tracked by #1399
domenic opened this issue Apr 3, 2024 · 2 comments · Fixed by #119
Closed
Tracked by #1399

Use of FrozenArray<>s for return types of methods is probably unnecessary #117

domenic opened this issue Apr 3, 2024 · 2 comments · Fixed by #119

Comments

@domenic
Copy link

domenic commented Apr 3, 2024

The spec has two methods, getHitTestResults() and getHitTestResultsForTransientInput(), which return FrozenArray<>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 whatwg/webidl#1399.

@toji
Copy link
Member

toji commented Jun 5, 2024

/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.

@toji
Copy link
Member

toji commented Jun 11, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants