mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 15:28:04 +08:00
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:
@@ -508,6 +508,7 @@ where
|
||||
H: BuildHasher + Default,
|
||||
{
|
||||
struct HashMapVisitor<K, V, H> {
|
||||
#[allow(clippy::type_complexity)]
|
||||
marker: std::marker::PhantomData<fn() -> HashMap<K, V, H>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -50,15 +50,13 @@ wasm-bindgen-futures = { workspace = true }
|
||||
# Workspace dependencies
|
||||
winit = { workspace = true }
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = { version = "0.3", features = ["html_reports"] }
|
||||
criterion = { version = "0.5", features = ["html_reports"] }
|
||||
glob = "0.3"
|
||||
pprof = { version = "0.13", features = ["flamegraph"] }
|
||||
serde_json = { workspace = true }
|
||||
graph-craft = { workspace = true, features = ["serde"] }
|
||||
|
||||
|
||||
[[bench]]
|
||||
name = "compile_demo_art"
|
||||
harness = false
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use graph_craft::{document::NodeNetwork, graphene_compiler::Compiler, proto::ProtoNetwork};
|
||||
use graph_craft::document::NodeNetwork;
|
||||
use graph_craft::graphene_compiler::Compiler;
|
||||
use graph_craft::proto::ProtoNetwork;
|
||||
|
||||
pub fn compile_to_proto(c: &mut Criterion) {
|
||||
let artworks = glob::glob("../../demo-artwork/*.graphite").expect("failed to read glob pattern");
|
||||
@@ -14,9 +16,8 @@ pub fn compile_to_proto(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
fn load_network(document_string: &str) -> NodeNetwork {
|
||||
let document: serde_json::Value = serde_json::from_str(&document_string).expect("Failed to parse document");
|
||||
let network = serde_json::from_value::<NodeNetwork>(document["network_interface"]["network"].clone()).expect("Failed to parse document");
|
||||
network
|
||||
let document: serde_json::Value = serde_json::from_str(document_string).expect("Failed to parse document");
|
||||
serde_json::from_value::<NodeNetwork>(document["network_interface"]["network"].clone()).expect("Failed to parse document")
|
||||
}
|
||||
fn compile(network: NodeNetwork) -> ProtoNetwork {
|
||||
let compiler = Compiler {};
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -370,7 +370,7 @@ async fn imaginate_maybe_fail<'a, P: Pixel, F: Fn(ImaginateStatus)>(
|
||||
prompt: prompt.await,
|
||||
seed: seed.await,
|
||||
steps: samples.await,
|
||||
cfg_scale: prompt_guidance.await as f64,
|
||||
cfg_scale: prompt_guidance.await,
|
||||
width: res.x,
|
||||
height: res.y,
|
||||
restore_faces: improve_faces.await,
|
||||
@@ -385,7 +385,7 @@ async fn imaginate_maybe_fail<'a, P: Pixel, F: Fn(ImaginateStatus)>(
|
||||
override_settings: Default::default(),
|
||||
|
||||
init_images: vec![base64_data],
|
||||
denoising_strength: image_creativity.await as f64 * 0.01,
|
||||
denoising_strength: image_creativity.await * 0.01,
|
||||
mask: None,
|
||||
};
|
||||
let url = join_url(&base_url, SDAPI_IMAGE_TO_IMAGE)?;
|
||||
|
||||
Reference in New Issue
Block a user