- s = ord(s) # FIXME
- for i in xrange(channels):
- curbit = (s & (1 << i) != 0)
- if (oldbit[i] == 0 and curbit == 1):
+ # Optimization: Skip identical bytes (no transitions).
+ if oldbyte == s:
+ continue
+ for i in range(channels):
+ curbit = (s & (1 << i)) >> i
+ # Optimization: Skip identical bits (no transitions).
+ if oldbit[i] == curbit:
+ continue
+ elif (oldbit[i] == 0 and curbit == 1):