Skip to content

Commit 21262b1

Browse files
David Tolnayfacebook-github-bot
David Tolnay
authored andcommitted
Resolve needless_as_bytes clippy lint
Summary: ```lang=text warning: needless call to `as_bytes()` --> fbcode/buck2/allocative/allocative/src/key.rs:55:19 | 55 | while i < s.as_bytes().len() { | ^^^^^^^^^^^^^^^^^^ help: `len()` can be called directly on strings: `s.len()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_as_bytes = note: `-W clippy::needless-as-bytes` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_as_bytes)]` warning: needless call to `as_bytes()` --> fbcode/buck2/allocative/allocative_derive/src/derive_allocative.rs:35:15 | 35 | while i < s.as_bytes().len() { | ^^^^^^^^^^^^^^^^^^ help: `len()` can be called directly on strings: `s.len()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_as_bytes = note: `-W clippy::needless-as-bytes` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_as_bytes)]` warning: needless call to `as_bytes()` --> fbcode/buck2/app/buck2_core/src/ascii_char_set.rs:20:20 | 20 | while i != chars.as_bytes().len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: `len()` can be called directly on strings: `chars.len()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_as_bytes = note: `-W clippy::needless-as-bytes` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_as_bytes)]` warning: needless call to `as_bytes()` --> fbcode/buck2/app/buck2_core/src/pattern/ascii_pattern.rs:114:40 | 114 | debug_assert!(start <= s.as_bytes().len() - 1); | ^^^^^^^^^^^^^^^^^^ help: `len()` can be called directly on strings: `s.len()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_as_bytes warning: needless call to `as_bytes()` --> fbcode/buck2/app/buck2_core/src/pattern/ascii_pattern.rs:118:55 | 118 | s.as_bytes().get_unchecked(start..s.as_bytes().len() - 1), | ^^^^^^^^^^^^^^^^^^ help: `len()` can be called directly on strings: `s.len()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_as_bytes errors: 0; warnings: 5 ``` Reviewed By: JakobDegen Differential Revision: D72681966 fbshipit-source-id: 612a7f69d7b029b3d4cb8d1c4f431454aa036e48
1 parent eb297d1 commit 21262b1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

allocative/allocative/src/key.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl Key {
5252
const fn hash(s: &str) -> u64 {
5353
let mut hash = 0xcbf29ce484222325;
5454
let mut i = 0;
55-
while i < s.as_bytes().len() {
55+
while i < s.len() {
5656
let b = s.as_bytes()[i];
5757
hash ^= b as u64;
5858
hash = hash.wrapping_mul(0x100000001b3);

allocative/allocative_derive/src/derive_allocative.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use syn::Variant;
3232
const fn hash(s: &str) -> u64 {
3333
let mut hash = 0xcbf29ce484222325;
3434
let mut i = 0;
35-
while i < s.as_bytes().len() {
35+
while i < s.len() {
3636
let b = s.as_bytes()[i];
3737
hash ^= b as u64;
3838
hash = hash.wrapping_mul(0x100000001b3);

0 commit comments

Comments
 (0)