diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2012-02-01 23:14:29 +0100 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2012-02-01 23:18:25 +0100 |
commit | 7f7ea759ebdc854beb0468b410f7d2382f291a4f (patch) | |
tree | 079e608f706706609d7fb95b81c485cc548a8396 /decoders | |
parent | 156509ca42f0df2380c9f205f9aad337e1a07802 (diff) | |
download | libsigrokdecode-7f7ea759ebdc854beb0468b410f7d2382f291a4f.tar.gz libsigrokdecode-7f7ea759ebdc854beb0468b410f7d2382f291a4f.zip |
srd: Properly use append() for appending to lists.
This is not only the canonical way to do it, it's also quite a bit faster
and less memory-intensive than using '+='.
Diffstat (limited to 'decoders')
-rw-r--r-- | decoders/ebr30a_i2c_demux/ebr30a_i2c_demux.py | 2 | ||||
-rw-r--r-- | decoders/i2cdemux/i2cdemux.py | 8 | ||||
-rw-r--r-- | decoders/mlx90614/mlx90614.py | 4 | ||||
-rw-r--r-- | decoders/mx25lxx05d/mx25lxx05d.py | 2 | ||||
-rw-r--r-- | decoders/transitioncounter/transitioncounter.py | 3 |
5 files changed, 10 insertions, 9 deletions
diff --git a/decoders/ebr30a_i2c_demux/ebr30a_i2c_demux.py b/decoders/ebr30a_i2c_demux/ebr30a_i2c_demux.py index 1a52fb8..50a1dbe 100644 --- a/decoders/ebr30a_i2c_demux/ebr30a_i2c_demux.py +++ b/decoders/ebr30a_i2c_demux/ebr30a_i2c_demux.py @@ -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)) diff --git a/decoders/i2cdemux/i2cdemux.py b/decoders/i2cdemux/i2cdemux.py index a597188..c4c0d3b 100644 --- a/decoders/i2cdemux/i2cdemux.py +++ b/decoders/i2cdemux/i2cdemux.py @@ -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': diff --git a/decoders/mlx90614/mlx90614.py b/decoders/mlx90614/mlx90614.py index f50e568..4fa8a0d 100644 --- a/decoders/mlx90614/mlx90614.py +++ b/decoders/mlx90614/mlx90614.py @@ -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 diff --git a/decoders/mx25lxx05d/mx25lxx05d.py b/decoders/mx25lxx05d/mx25lxx05d.py index 801ab80..fa05205 100644 --- a/decoders/mx25lxx05d/mx25lxx05d.py +++ b/decoders/mx25lxx05d/mx25lxx05d.py @@ -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: diff --git a/decoders/transitioncounter/transitioncounter.py b/decoders/transitioncounter/transitioncounter.py index 4b458b2..44dda48 100644 --- a/decoders/transitioncounter/transitioncounter.py +++ b/decoders/transitioncounter/transitioncounter.py @@ -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) |