pyloxi: optimize unpack_list
diff --git a/py_gen/templates/util.py b/py_gen/templates/util.py
index bfe11d0..fead78f 100644
--- a/py_gen/templates/util.py
+++ b/py_gen/templates/util.py
@@ -52,7 +52,8 @@
     entries = []
     offset = 0
     length_struct = struct.Struct(length_fmt)
-    while offset < len(buf):
+    n = len(buf)
+    while offset < n:
         if offset + length_struct.size > len(buf): raise loxi.ProtocolError("entry header overruns list length")
         length, = length_struct.unpack_from(buf, offset)
         if length < length_struct.size: raise loxi.ProtocolError("entry length is less than the header length")