-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Implement nth
for EscapeUnicode
#33932
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
Conversation
Extract a function that updates the iterator state and returns the result of an arbitrary step of iteration. This implements the same logic as `next`, but it can be shared with `nth`.
as a step from the appropriate state. Part of rust-lang#24214.
This makes it easier to have a unique path for handling all of them.
by extracting a shared `step` function.
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
Given that he has already reviewed the previous PRs, r? @alexcrichton |
This... seems like a lot of code for a pretty minor feature. Out of curiosity is there a crate which is actually exercising this in terms of desiring performance gains or are these just being done for completeness? If they're only done for completeness I'd somewhat prefer to hold off on the extra complexity for now. |
Is it definitely a perf win? I spent a while looking at this patch before deciding I didn't understand it enough to review. So I sort of agree with alex that it may not be worth the churn. |
A little less churn would be possible by implementing The changes to The implementation of I agree that there is little use for this micro-optimisation (especially considered that the offsetting logic is not completely obvious at first sight), so it can probably be held off with no disadvantage. |
Ok, in that case it seems fine to close this for now and we can revisit if it becomes a perf hazard for someone? |
and cleanup the code for
nth
forEscapeDefault
by sharing the stepping logic betweennth
andnext
.Part of #24214, split from #31049 (last part! :) ).
The test for
nth
was added in #33103.