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

Array: Relax slice bound checks to properly handle negative indices #56668

Merged

Commits on Jan 10, 2022

  1. Array: Relax slice bound checks to properly handle negative indices

    The same is done for `Vector` (and thus `Packed*Array`).
    
    `begin` and `end` can now take any value and will be clamped to
    `[-size(), size()]`. Negative values are a shorthand for indexing the array
    from the last element upward.
    
    `end` is given a default `INT_MAX` value (which will be clamped to `size()`)
    so that the `end` parameter can be omitted to go from `begin` to the max size
    of the array.
    
    This makes `slice` works similarly to numpy's and JavaScript's.
    akien-mga committed Jan 10, 2022
    Configuration menu
    Copy the full SHA
    c6cefb1 View commit details
    Browse the repository at this point in the history