From 77f7609b67199a4a41a0810e1686ad0cf5f9ab2a Mon Sep 17 00:00:00 2001 From: Cary R Date: Tue, 22 Aug 2023 20:40:15 -0700 Subject: [PATCH] Fix formatting of link routine --- vvp/vvp_net.cc | 53 +++++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index a5a2ed870..ef995d57e 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2004-2023 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -200,42 +200,37 @@ void vvp_net_t::link(vvp_net_ptr_t port_to_link) { vvp_net_t*net = port_to_link.ptr(); - // Connect nodes with vvp_fun_modpath_src to the head of the - // linked list, so that vvp_fun_modpath_src are always evaluated - // before their respective vvp_fun_modpath - if (dynamic_cast(net->fun)) - { - net->port[port_to_link.port()] = out_; - out_ = port_to_link; - } - // All other nodes connect after the last vvp_fun_modpath_src - else - { + // Connect nodes with vvp_fun_modpath_src to the head of the + // linked list, so that vvp_fun_modpath_src are always evaluated + // before their respective vvp_fun_modpath + if (dynamic_cast(net->fun)) { + net->port[port_to_link.port()] = out_; + out_ = port_to_link; + // All other nodes connect after the last vvp_fun_modpath_src + } else { // List is empty or first node has no vvp_fun_modpath_src // then just insert the node into the head of linked list - if (out_.ptr() == nullptr || ! dynamic_cast(out_.ptr()->fun)) - { - net->port[port_to_link.port()] = out_; - out_ = port_to_link; - return; - } + if (out_.ptr() == nullptr || ! dynamic_cast(out_.ptr()->fun)) { + net->port[port_to_link.port()] = out_; + out_ = port_to_link; + return; + } - vvp_net_ptr_t cur = out_; - vvp_net_ptr_t prev = vvp_net_ptr_t(nullptr,0); + vvp_net_ptr_t cur = out_; + vvp_net_ptr_t prev = vvp_net_ptr_t(nullptr,0); // Traverse through linked list - while (dynamic_cast(cur.ptr()->fun)) - { - prev = cur; - cur = cur.ptr()->port[cur.port()]; - if (!cur.ptr()) break; // End of list - } + while (dynamic_cast(cur.ptr()->fun)) { + prev = cur; + cur = cur.ptr()->port[cur.port()]; + if (! cur.ptr()) break; // End of list + } - assert(prev.ptr()); + assert(prev.ptr()); // Insert after last vvp_fun_modpath_src (or end of list) - net->port[port_to_link.port()] = cur; - prev.ptr()->port[prev.port()] = port_to_link; + net->port[port_to_link.port()] = cur; + prev.ptr()->port[prev.port()] = port_to_link; } }