Page MenuHomePhabricator

[lib] [web] Use `slice(0, -1)` instead of `slice(0, ...length - 1)`
ClosedPublic

Authored by abosh on Jun 21 2022, 11:49 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 24, 4:08 AM
Unknown Object (File)
Sun, Nov 24, 12:17 AM
Unknown Object (File)
Sat, Nov 2, 2:33 PM
Unknown Object (File)
Oct 7 2024, 10:14 PM
Unknown Object (File)
Oct 7 2024, 10:14 PM
Unknown Object (File)
Oct 7 2024, 10:14 PM
Unknown Object (File)
Oct 7 2024, 10:11 PM
Unknown Object (File)
Oct 5 2024, 12:10 PM
Subscribers

Details

Summary

Noticed some instances of slice() being called with the length property of the array that was being sliced instead of the more concise syntax using negative indices.

Test Plan

N/A, but checked to make sure slice() functions the same with the negative index and when called with its positive counterpart (...length - 1, for example).

Diff Detail

Repository
rCOMM Comm
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

This makes sense to me, I tend to use negative indices liberally when I'm writing python or whatever.

Kind of a style thing so tagging @ashoat to see if he cares/has any thoughts

This revision is now accepted and ready to land.Jun 21 2022, 12:06 PM

Makes sense. Also wanted to note that slice(0, -1) is what's used in the rest of the codebase, i.e., this change updates the only usages of slice() that don't already use the negative index syntax.

In D4316#121640, @yayabosh wrote:

Makes sense. Also wanted to note that slice(0, -1) is what's used in the rest of the codebase, i.e., this change updates the only usages of slice() that don't already use the negative index syntax.

Okay cool, then it's probably good to land