back.pysim: Eliminate duplicate dict lookup in VCD update
authorStuart Olsen <stuart@sj-olsen.com>
Tue, 7 Apr 2020 05:22:45 +0000 (22:22 -0700)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 31 Dec 2021 13:24:31 +0000 (13:24 +0000)
nmigen/back/pysim.py

index f0fa2da99ec890ff328823fb81b8c4fd4e6a9a72..dfe2ab565d099c27dfc1e5d22a45b96c7fc6d7a8 100644 (file)
@@ -132,7 +132,8 @@ class _VCDWaveformWriter(_WaveformWriter):
                     self.gtkw_names[signal] = (*var_scope, var_name_suffix)
 
     def update(self, timestamp, signal, value):
-        if signal not in self.vcd_vars:
+        vcd_vars = self.vcd_vars.get(signal)
+        if vcd_vars is None:
             return
 
         vcd_timestamp = self.timestamp_to_vcd(timestamp)
@@ -140,7 +141,7 @@ class _VCDWaveformWriter(_WaveformWriter):
             var_value = self.decode_to_vcd(signal, value)
         else:
             var_value = value
-        for vcd_var in self.vcd_vars[signal]:
+        for vcd_var in vcd_vars:
             self.vcd_writer.change(vcd_var, vcd_timestamp, var_value)
 
     def close(self, timestamp):