mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Fix assorted Clippy lints (#3390)
This commit is contained in:
@@ -686,10 +686,10 @@ impl NodeNetwork {
|
||||
fn replace_node_inputs(&mut self, node_id: NodeId, old_input: (NodeId, usize), new_input: (NodeId, usize)) {
|
||||
let Some(node) = self.nodes.get_mut(&node_id) else { return };
|
||||
node.inputs.iter_mut().for_each(|input| {
|
||||
if let NodeInput::Node { node_id: input_id, output_index, .. } = input {
|
||||
if (*input_id, *output_index) == old_input {
|
||||
(*input_id, *output_index) = new_input;
|
||||
}
|
||||
if let NodeInput::Node { node_id: input_id, output_index, .. } = input
|
||||
&& (*input_id, *output_index) == old_input
|
||||
{
|
||||
(*input_id, *output_index) = new_input;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -738,10 +738,10 @@ impl NodeNetwork {
|
||||
let mut are_inputs_used = vec![false; number_of_inputs];
|
||||
for node in &self.nodes {
|
||||
for node_input in &node.1.inputs {
|
||||
if let NodeInput::Import { import_index, .. } = node_input {
|
||||
if let Some(is_used) = are_inputs_used.get_mut(*import_index) {
|
||||
*is_used = true;
|
||||
}
|
||||
if let NodeInput::Import { import_index, .. } = node_input
|
||||
&& let Some(is_used) = are_inputs_used.get_mut(*import_index)
|
||||
{
|
||||
*is_used = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -937,50 +937,48 @@ impl NodeNetwork {
|
||||
|
||||
fn remove_id_node(&mut self, id: NodeId) -> Result<(), String> {
|
||||
let node = self.nodes.get(&id).ok_or_else(|| format!("Node with id {id} does not exist"))?.clone();
|
||||
if let DocumentNodeImplementation::ProtoNode(ident) = &node.implementation {
|
||||
if ident.name == "graphene_core::ops::IdentityNode" {
|
||||
assert_eq!(node.inputs.len(), 1, "Id node has more than one input");
|
||||
if let NodeInput::Node { node_id, output_index, .. } = node.inputs[0] {
|
||||
let node_input_output_index = output_index;
|
||||
// TODO fix
|
||||
if let Some(input_node) = self.nodes.get_mut(&node_id) {
|
||||
for &dep in &node.original_location.dependants[0] {
|
||||
input_node.original_location.dependants[output_index].push(dep);
|
||||
if let DocumentNodeImplementation::ProtoNode(ident) = &node.implementation
|
||||
&& *ident == graphene_core::ops::identity::IDENTIFIER
|
||||
{
|
||||
assert_eq!(node.inputs.len(), 1, "Id node has more than one input");
|
||||
if let NodeInput::Node { node_id, output_index, .. } = node.inputs[0] {
|
||||
let node_input_output_index = output_index;
|
||||
// TODO fix
|
||||
if let Some(input_node) = self.nodes.get_mut(&node_id) {
|
||||
for &dep in &node.original_location.dependants[0] {
|
||||
input_node.original_location.dependants[output_index].push(dep);
|
||||
}
|
||||
}
|
||||
|
||||
let input_node_id = node_id;
|
||||
for output in self.nodes.values_mut() {
|
||||
for (index, input) in output.inputs.iter_mut().enumerate() {
|
||||
if let NodeInput::Node {
|
||||
node_id: output_node_id,
|
||||
output_index: output_output_index,
|
||||
..
|
||||
} = input && *output_node_id == id
|
||||
{
|
||||
*output_node_id = input_node_id;
|
||||
*output_output_index = node_input_output_index;
|
||||
|
||||
let input_source = &mut output.original_location.inputs_source;
|
||||
for source in node.original_location.inputs(index) {
|
||||
input_source.insert(source, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let input_node_id = node_id;
|
||||
for output in self.nodes.values_mut() {
|
||||
for (index, input) in output.inputs.iter_mut().enumerate() {
|
||||
if let NodeInput::Node {
|
||||
node_id: output_node_id,
|
||||
output_index: output_output_index,
|
||||
..
|
||||
} = input
|
||||
{
|
||||
if *output_node_id == id {
|
||||
*output_node_id = input_node_id;
|
||||
*output_output_index = node_input_output_index;
|
||||
|
||||
let input_source = &mut output.original_location.inputs_source;
|
||||
for source in node.original_location.inputs(index) {
|
||||
input_source.insert(source, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for node_input in self.exports.iter_mut() {
|
||||
if let NodeInput::Node { node_id, output_index, .. } = node_input {
|
||||
if *node_id == id {
|
||||
*node_id = input_node_id;
|
||||
*output_index = node_input_output_index;
|
||||
}
|
||||
}
|
||||
for node_input in self.exports.iter_mut() {
|
||||
if let NodeInput::Node { node_id, output_index, .. } = node_input
|
||||
&& *node_id == id
|
||||
{
|
||||
*node_id = input_node_id;
|
||||
*output_index = node_input_output_index;
|
||||
}
|
||||
}
|
||||
}
|
||||
self.nodes.remove(&id);
|
||||
}
|
||||
self.nodes.remove(&id);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -1047,15 +1045,15 @@ impl NodeNetwork {
|
||||
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 {
|
||||
if let NodeInput::Node { node_id, .. } = self.exports[0] {
|
||||
return vec![ProtoNetwork {
|
||||
inputs: Vec::new(),
|
||||
output: node_id,
|
||||
nodes,
|
||||
}]
|
||||
.into_iter();
|
||||
}
|
||||
if self.exports.len() == 1
|
||||
&& let NodeInput::Node { node_id, .. } = self.exports[0]
|
||||
{
|
||||
return vec![ProtoNetwork {
|
||||
inputs: Vec::new(),
|
||||
output: node_id,
|
||||
nodes,
|
||||
}]
|
||||
.into_iter();
|
||||
}
|
||||
|
||||
// Create a network to evaluate each output
|
||||
|
||||
Reference in New Issue
Block a user