mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-26 13:20:32 +01:00
Fix misc clippy warnings
Why does it want me to use bytecount? It's not even faster
This commit is contained in:
@@ -5,6 +5,7 @@ authors = ["Bert Peters <bert@bertptrs.nl>"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
bytecount = "0.6"
|
||||||
clap = "3.0.0-beta.2"
|
clap = "3.0.0-beta.2"
|
||||||
itertools = "0.9"
|
itertools = "0.9"
|
||||||
num-integer = "0.1"
|
num-integer = "0.1"
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::mem::swap;
|
use std::mem::swap;
|
||||||
|
|
||||||
|
use bytecount::naive_count_32;
|
||||||
|
|
||||||
use crate::common::read_char_grid;
|
use crate::common::read_char_grid;
|
||||||
use crate::Solution;
|
use crate::Solution;
|
||||||
|
|
||||||
@@ -9,12 +11,12 @@ fn neighbours(grid: &[Vec<u8>], r: usize, c: usize) -> usize {
|
|||||||
|
|
||||||
if r > 0 {
|
if r > 0 {
|
||||||
let range = c.saturating_sub(1)..grid[r - 1].len().min(c + 2);
|
let range = c.saturating_sub(1)..grid[r - 1].len().min(c + 2);
|
||||||
n += grid[r - 1][range].iter().filter(|&&s| s == b'#').count();
|
n += naive_count_32(&grid[r - 1][range], b'#');
|
||||||
}
|
}
|
||||||
|
|
||||||
if r < grid.len() - 1 {
|
if r < grid.len() - 1 {
|
||||||
let range = c.saturating_sub(1)..grid[r + 1].len().min(c + 2);
|
let range = c.saturating_sub(1)..grid[r + 1].len().min(c + 2);
|
||||||
n += grid[r + 1][range].iter().filter(|&&s| s == b'#').count();
|
n += naive_count_32(&grid[r + 1][range], b'#');
|
||||||
}
|
}
|
||||||
|
|
||||||
if c > 0 && grid[r][c - 1] == b'#' {
|
if c > 0 && grid[r][c - 1] == b'#' {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ fn x_mask_permutations(mut x_mask: u64, permutations: &mut Vec<u64>) {
|
|||||||
while x_mask > 0 {
|
while x_mask > 0 {
|
||||||
let trailing = x_mask.trailing_zeros();
|
let trailing = x_mask.trailing_zeros();
|
||||||
|
|
||||||
let bit = 1 << trailing + offset;
|
let bit = 1 << (trailing + offset);
|
||||||
|
|
||||||
x_mask >>= trailing + 1;
|
x_mask >>= trailing + 1;
|
||||||
offset += trailing + 1;
|
offset += trailing + 1;
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ fn split_nums<'a>(s: &'a str) -> impl Iterator<Item = u32> + 'a {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clippy allow here because this type is used exactly once
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
fn read_input(input: &mut dyn Read) -> (HashMap<String, Vec<RangeInclusive<u32>>>, Vec<Vec<u32>>) {
|
fn read_input(input: &mut dyn Read) -> (HashMap<String, Vec<RangeInclusive<u32>>>, Vec<Vec<u32>>) {
|
||||||
let mut lines = Lines::new(input).filter(|s| !s.is_empty());
|
let mut lines = Lines::new(input).filter(|s| !s.is_empty());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user