-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Iterator specialization for EscapeDefaults #30624
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
99c7702
to
8012f29
Compare
EscapeDefaultState::Unicode(ref mut i) => return i.nth(n), | ||
}; | ||
|
||
let start = if let Some(x) = self.get_offset() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be convenient to fold this into the previous match?
I did something similar here: ranma42@0cdfa6d
Does this commit complete the tasks listed in #24214 ? AFAICT |
@ranma42 Interesting. It's true that it doesn't fix the EscapeUnicode. Have you tried to send a pull request? |
I will send one soon. I had some unresolved questions, though, about how to handle code duplication and whether the methods should be |
@ranma42 I don't think they should be so. They're not simple enough for inlining to be worth it. |
r? @aturon |
I believe that the test should be moved to |
} else { | ||
return None; | ||
}; | ||
let idx = start + n; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sum can overflow if when n = usize::MAX
and start = 1
(i.e. self.state
is Char(_)
).
@alexcrichton I have now fixed the comments you gave. |
EscapeDefaultState::Unicode(ref mut i) => return i.nth(n), | ||
}; | ||
|
||
let start = if let Some(x) = self.get_offset() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method may not be necessary as it can just be folded into the match
above
@alexcrichton I updated it to reflect your points. |
@alexcrichton I have a branch which specialises |
Ok, we can perhaps try to unify once they both exist, but at least for now this seems more understandable to me at least. @ticki, can you also squash the commits together? Other than that looks good to me, thanks! |
@alexcrichton Yep. Will do. |
Squash done! |
Looks like some other snuck in by accident? |
Damn. Will fix. |
…e tests to libcoretest Remove unused import Fold nth() method into the match expr
@alexcrichton Fixed. |
Part of #30520. Completes #24214