Skip to content

Conversation

@froydnj
Copy link
Contributor

@froydnj froydnj commented Nov 1, 2025

Getting the length of a NodeList currently requires using count():

https://github.com/fables-tales/rubyfmt/blob/ab02a7888892bbc34d05a70e304d95806f8a83f4/librubyfmt/src/format_prism.rs#L659-L660

I think the compiler might be smart enough to unroll the loop and collapse down the iterations to compute the actual size in constant time, but why create work for the compiler if you don't have to?

@froydnj froydnj changed the title [rust] add size function for NodeList [rust] add len function for NodeList Nov 2, 2025
@kddnewton kddnewton merged commit 2ecd49d into ruby:main Nov 2, 2025
62 checks passed
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 this pull request may close these issues.

2 participants