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)
Thu, Jun 20, 6:26 AM
Unknown Object (File)
Thu, Jun 13, 7:52 AM
Unknown Object (File)
Wed, Jun 12, 11:51 PM
Unknown Object (File)
Thu, Jun 6, 12:06 PM
Unknown Object (File)
Thu, Jun 6, 8:25 AM
Unknown Object (File)
Thu, Jun 6, 7:26 AM
Unknown Object (File)
Jun 3 2024, 12:13 PM
Unknown Object (File)
May 27 2024, 3:44 AM
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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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