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

Implement nth, count, and last for EscapeUnicode #31049

Closed
wants to merge 10 commits into from

Commits on Jan 20, 2016

  1. Unify computation of length in EscapeUnicode

    The `offset` value was computed both in `next` and in `size_hint`;
    computing it in a single place ensures consistency and makes it easier
    to apply improvements. The value is now computed as soon as the
    iterator is constructed. This means that the time to compute it is
    spent immediately and cannot be avoided, but it also guarantees that
    it is only spent once.
    ranma42 committed Jan 20, 2016
    Configuration menu
    Copy the full SHA
    37a614e View commit details
    Browse the repository at this point in the history
  2. Improve computation of EscapeUnicode offset field

    Instead of iteratively scanning the bits, use `leading_zeros`.
    ranma42 committed Jan 20, 2016
    Configuration menu
    Copy the full SHA
    1027e6a View commit details
    Browse the repository at this point in the history
  3. EscapeUnicode and EscapeDefault are ExactSizeIterators

    In rust-lang#28662, `size_hint` was made exact for `EscapeUnicode` and
    `EscapeDefault`, but neither was marked as `ExactSizeIterator`.
    ranma42 committed Jan 20, 2016
    Configuration menu
    Copy the full SHA
    7f5eae7 View commit details
    Browse the repository at this point in the history
  4. Implement count for EscapeDefault and EscapeUnicode

    Trivial implementation, as both are `ExactSizeIterator`s.
    
    Part of rust-lang#24214.
    ranma42 committed Jan 20, 2016
    Configuration menu
    Copy the full SHA
    009e243 View commit details
    Browse the repository at this point in the history
  5. Implement last for EscapeUnicode

    ranma42 committed Jan 20, 2016
    Configuration menu
    Copy the full SHA
    ad7f68d View commit details
    Browse the repository at this point in the history
  6. Move length computation to ExactSizeIterator impls

    and reuse it in `size_hint`.
    ranma42 committed Jan 20, 2016
    Configuration menu
    Copy the full SHA
    113b366 View commit details
    Browse the repository at this point in the history
  7. Extract stepping from EscapeUnicode::next

    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`.
    ranma42 committed Jan 20, 2016
    Configuration menu
    Copy the full SHA
    f6c8757 View commit details
    Browse the repository at this point in the history
  8. Implement EscapeUnicode::nth

    as a step from the appropriate state.
    
    Part of rust-lang#24214.
    ranma42 committed Jan 20, 2016
    Configuration menu
    Copy the full SHA
    23c5da0 View commit details
    Browse the repository at this point in the history
  9. Use the same structure for non-Unicode variants of EscapeDefaultState

    This makes it easier to have a unique path for handling all of them.
    ranma42 committed Jan 20, 2016
    Configuration menu
    Copy the full SHA
    90ddfc7 View commit details
    Browse the repository at this point in the history
  10. Unify EscapeDefault::next and EscapeDefault::nth

    by extracting a shared `step` function.
    ranma42 committed Jan 20, 2016
    Configuration menu
    Copy the full SHA
    266da8e View commit details
    Browse the repository at this point in the history