viff

changeset 1162:83282f6e20b9

Take advantage of the repeat count in format strings.
author Martin Geisler <mg@cs.au.dk>
date Tue, 14 Apr 2009 23:30:34 +0200
parents 8c7d9f684b56
children 65cce3c355a0
files viff/runtime.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/viff/runtime.py	Tue Apr 14 23:20:08 2009 +0200
     1.2 +++ b/viff/runtime.py	Tue Apr 14 23:30:34 2009 +0200
     1.3 @@ -305,7 +305,7 @@
     1.4              # TODO: we cannot handle the empty string
     1.5              # also note that we cannot handle pcs longer than 256
     1.6              pc_size = ord(string[0])
     1.7 -            fmt = (pc_size + 1)*'i'
     1.8 +            fmt = "%di" % (pc_size + 1)
     1.9              predata_size = struct.calcsize(fmt) + 1
    1.10              fmt = "%s%is" % (fmt, len(string)-predata_size)
    1.11  
    1.12 @@ -327,7 +327,7 @@
    1.13  
    1.14      def sendData(self, program_counter, data_type, data):
    1.15          pc_size = len(program_counter)
    1.16 -        fmt = "%s%is" % ((pc_size + 1)*'i', len(data))
    1.17 +        fmt = "%di%ds" % (pc_size + 1, len(data))
    1.18          data_tuple = program_counter + (data_type, data)
    1.19  
    1.20          self.sendString(chr(pc_size) + struct.pack(fmt, *data_tuple))