]> sigrok.org Git - libsigrokdecode.git/commitdiff
srd: Properly use append() for appending to lists.
authorUwe Hermann <redacted>
Wed, 1 Feb 2012 22:14:29 +0000 (23:14 +0100)
committerUwe Hermann <redacted>
Wed, 1 Feb 2012 22:18:25 +0000 (23:18 +0100)
This is not only the canonical way to do it, it's also quite a bit faster
and less memory-intensive than using '+='.

decoders/ebr30a_i2c_demux/ebr30a_i2c_demux.py
decoders/i2cdemux/i2cdemux.py
decoders/mlx90614/mlx90614.py
decoders/mx25lxx05d/mx25lxx05d.py
decoders/transitioncounter/transitioncounter.py

index 1a52fb8a0344586692cfabd5a0c49ee029ea8fd4..50a1dbe938a36f16bb187820f882e53720cc63d3 100644 (file)
@@ -67,7 +67,7 @@ class Decoder(srd.Decoder):
         cmd, databyte, ack_bit = data
 
         # Add the I2C packet to our local cache.
-        self.packets += [[ss, es, data]]
+        self.packets.append([ss, es, data])
 
         if cmd in ('ADDRESS READ', 'ADDRESS WRITE'):
             # print(hex(databyte))
index a597188fc95b695e3ff8c4de76cdac6723a9c48c..c4c0d3b09fe68150415aa744eda3f24adf640fc7 100644 (file)
@@ -60,7 +60,7 @@ class Decoder(srd.Decoder):
         cmd, databyte, ack = data
 
         # Add the I2C packet to our local cache.
-        self.packets += [[ss, es, data]]
+        self.packets.append([ss, es, data])
 
         if cmd in ('ADDRESS READ', 'ADDRESS WRITE'):
             if databyte in self.slaves:
@@ -68,9 +68,9 @@ class Decoder(srd.Decoder):
                 return
 
             # We're never seen this slave, add a new stream.
-            self.slaves += [databyte]
-            self.out_proto += [self.add(srd.OUTPUT_PROTO,
-                               'i2c-%s' % hex(databyte))]
+            self.slaves.append(databyte)
+            self.out_proto.append(self.add(srd.OUTPUT_PROTO,
+                                  'i2c-%s' % hex(databyte)))
             self.stream = self.streamcount
             self.streamcount += 1
         elif cmd == 'STOP':
index f50e56882123d419d152ead60e35c916434638f1..4fa8a0d94846f134c01910842b2340d159f91d06 100644 (file)
@@ -69,10 +69,10 @@ class Decoder(srd.Decoder):
             self.state = 'GET TEMPERATURE'
         elif self.state == 'GET TEMPERATURE':
             if len(self.data) == 0:
-                self.data += [databyte]
+                self.data.append(databyte)
                 self.ss = ss
             elif len(self.data) == 1:
-                self.data += [databyte]
+                self.data.append(databyte)
                 self.es = es
             else:
                 kelvin = (self.data[0] | (self.data[1] << 8)) * 0.02
index 801ab809c09aa3146a4f98dc764252bf732c9461..fa052058df34e17ea4fc29966b7313966371837c 100644 (file)
@@ -210,7 +210,7 @@ class Decoder(srd.Decoder):
             self.putx([0, ['%s ID' % d]])
         elif self.cmdstate == 6:
             # Byte 6: Slave sends device ID (or manufacturer ID).
-            self.ids += [miso]
+            self.ids.append(miso)
             d = 'Manufacturer' if self.manufacturer_id_first else 'Device'
             self.putx([0, ['%s ID' % d]])
         else:
index 4b458b2ed778a22bc56acb5f383275e01a92d7d3..44dda482527cdcee7838e98ffaad0da79456c9aa 100644 (file)
@@ -96,7 +96,8 @@ class Decoder(srd.Decoder):
         # TODO: How to only output something after the last chunk of data?
         outdata = []
         for i in range(self.channels):
-            outdata += [[self.transitions[i], self.rising[i], self.falling[i]]]
+            outdata.append([self.transitions[i], self.rising[i],
+                            self.falling[i]])
 
         if outdata != []:
             # self.put(0, 0, self.out_proto, out_proto)