Fix all Clippy warnings (#1936)

* Fix all Clippy warnings

* More fixes

* Bump criterion version

---------

Co-authored-by: dennis@kobert.dev <dennis@kobert.dev>
This commit is contained in:
Keavon Chambers
2024-08-14 10:05:08 -07:00
committed by GitHub
parent 858efb65bb
commit 15d125d8e7
13 changed files with 97 additions and 121 deletions

View File

@@ -2,12 +2,12 @@ use crate::document::value::TaggedValue;
use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput};
use dyn_any::{DynAny, StaticType};
use glam::IVec2;
use graphene_core::memo::MemoHashGuard;
pub use graphene_core::uuid::generate_uuid;
use graphene_core::{Cow, MemoHash, ProtoNodeIdentifier, Type};
use rustc_hash::{FxHashMap, FxHashSet};
use glam::IVec2;
use rustc_hash::FxHashMap;
use std::collections::hash_map::DefaultHasher;
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
@@ -1026,7 +1026,7 @@ impl NodeNetwork {
Self::replace_value_inputs_with_nodes(
&mut inner_network.exports,
&mut inner_network.nodes,
&node.original_location.path.as_ref().unwrap_or(&vec![]),
node.original_location.path.as_ref().unwrap_or(&vec![]),
gen_id,
map_ids,
id,
@@ -1058,9 +1058,8 @@ impl NodeNetwork {
NodeInput::Node { node_id, output_index, lambda } => {
let skip = node.original_location.skip_inputs;
nested_node.populate_first_network_input(node_id, output_index, nested_input_index, lambda, node.original_location.inputs(*import_index), skip);
if let input_node = self.nodes.get_mut(&node_id).unwrap() {
input_node.original_location.dependants[output_index].push(nested_node_id);
};
let input_node = self.nodes.get_mut(&node_id).unwrap();
input_node.original_location.dependants[output_index].push(nested_node_id);
}
NodeInput::Network { import_index, .. } => {
let parent_input_index = import_index;
@@ -1276,8 +1275,7 @@ impl NodeNetwork {
/// Creates a proto network for evaluating each output of this network.
pub fn into_proto_networks(self) -> impl Iterator<Item = ProtoNetwork> {
// let input_node = self.nodes.iter().find_map(|(node_id, node)| if node.name == "SetNode" { Some(node_id.clone()) } else { None });
let mut nodes: Vec<_> = self.nodes.into_iter().map(|(id, node)| (id, node.resolve_proto_node())).collect();
let nodes: Vec<_> = self.nodes.into_iter().map(|(id, node)| (id, node.resolve_proto_node())).collect();
// Create a network to evaluate each output
if self.exports.len() == 1 {
@@ -1285,7 +1283,7 @@ impl NodeNetwork {
return vec![ProtoNetwork {
inputs: Vec::new(),
output: node_id,
nodes: nodes,
nodes,
}]
.into_iter();
}

View File

@@ -3,8 +3,8 @@ use crate::document::{NodeId, OriginalLocation};
use dyn_any::DynAny;
use graphene_core::*;
use rustc_hash::{FxHashMap, FxHashSet};
use rustc_hash::FxHashMap;
#[cfg(feature = "serde")]
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
@@ -430,10 +430,7 @@ impl ProtoNetwork {
}
fn collect_inwards_edges_with_mapping(&self) -> (Vec<Vec<usize>>, FxHashMap<NodeId, usize>) {
let mut id_map = FxHashMap::with_capacity_and_hasher(self.nodes.len(), Default::default());
// Create dense mapping
id_map = self.nodes.iter().enumerate().map(|(idx, (id, _))| (*id, idx)).collect();
let id_map: FxHashMap<_, _> = self.nodes.iter().enumerate().map(|(idx, (id, _))| (*id, idx)).collect();
// Collect inwards edges using dense indices
let mut inwards_edges = vec![Vec::new(); self.nodes.len()];
@@ -584,7 +581,7 @@ impl ProtoNetwork {
/// Sort the nodes vec so it is in a topological order. This ensures that no node takes an input from a node that is found later in the list.
fn reorder_ids(&mut self) -> Result<(), String> {
let (order, id_map) = self.topological_sort()?;
let (order, _id_map) = self.topological_sort()?;
// // Map of node ids to their current index in the nodes vector
// let current_positions: FxHashMap<_, _> = self.nodes.iter().enumerate().map(|(pos, (id, _))| (*id, pos)).collect();