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 wrap: on
line diff
--- a/viff/runtime.py	Tue Apr 14 23:20:08 2009 +0200
+++ b/viff/runtime.py	Tue Apr 14 23:30:34 2009 +0200
@@ -305,7 +305,7 @@
             # TODO: we cannot handle the empty string
             # also note that we cannot handle pcs longer than 256
             pc_size = ord(string[0])
-            fmt = (pc_size + 1)*'i'
+            fmt = "%di" % (pc_size + 1)
             predata_size = struct.calcsize(fmt) + 1
             fmt = "%s%is" % (fmt, len(string)-predata_size)
 
@@ -327,7 +327,7 @@
 
     def sendData(self, program_counter, data_type, data):
         pc_size = len(program_counter)
-        fmt = "%s%is" % ((pc_size + 1)*'i', len(data))
+        fmt = "%di%ds" % (pc_size + 1, len(data))
         data_tuple = program_counter + (data_type, data)
 
         self.sendString(chr(pc_size) + struct.pack(fmt, *data_tuple))