From f4617104b609cd3e6c4cf3834e1263ad59bd2783 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Tue, 2 Sep 2025 02:10:15 +0000 Subject: [PATCH] Avoid unnecessary copying when applying a SigMap to a SigSpec Currently we duplicate the `SigSpec` first and then iterate over the duplicate, updating its bits. Instead just generate new bits and add them to an empty `SigSpec`. --- kernel/sigtools.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kernel/sigtools.h b/kernel/sigtools.h index 7962eaa70..3155d7482 100644 --- a/kernel/sigtools.h +++ b/kernel/sigtools.h @@ -259,10 +259,14 @@ struct SigMapView return bit; } - RTLIL::SigSpec operator()(RTLIL::SigSpec sig) const + RTLIL::SigSpec operator()(const RTLIL::SigSpec &sig) const { - apply(sig); - return sig; + RTLIL::SigSpec result; + for (RTLIL::SigBit bit : sig) { + apply(bit); + result.append(bit); + } + return result; } RTLIL::SigSpec operator()(RTLIL::Wire *wire) const