Kaydet (Commit) cce074e2 authored tarafından Guido van Rossum's avatar Guido van Rossum

new binhex from Jack (much faster)

üst 975aa22b
...@@ -131,20 +131,26 @@ class _Hqxcoderengine: ...@@ -131,20 +131,26 @@ class _Hqxcoderengine:
todo = (datalen/3)*3 todo = (datalen/3)*3
data = self.data[:todo] data = self.data[:todo]
self.data = self.data[todo:] self.data = self.data[todo:]
if not data:
return
self.hqxdata = self.hqxdata + binascii.b2a_hqx(data) self.hqxdata = self.hqxdata + binascii.b2a_hqx(data)
while len(self.hqxdata) > self.linelen: self._flush(0)
self.ofp.write(self.hqxdata[:self.linelen]+'\n')
self.hqxdata = self.hqxdata[self.linelen:] def _flush(self, force):
first = 0
while first <= len(self.hqxdata)-self.linelen:
last = first + self.linelen
self.ofp.write(self.hqxdata[first:last]+'\n')
self.linelen = LINELEN self.linelen = LINELEN
first = last
self.hqxdata = self.hqxdata[first:]
if force:
self.ofp.write(self.hqxdata + ':\n')
def close(self): def close(self):
if self.data: if self.data:
self.hqxdata = self.hqxdata + binascii.b2a_hqx(self.data) self.hqxdata = self.hqxdata + binascii.b2a_hqx(self.data)
while self.hqxdata: self._flush(1)
self.ofp.write(self.hqxdata[:self.linelen])
self.hqxdata = self.hqxdata[self.linelen:]
self.linelen = LINELEN
self.ofp.write(':\n')
self.ofp.close() self.ofp.close()
del self.ofp del self.ofp
...@@ -290,7 +296,6 @@ class _Hqxdecoderengine: ...@@ -290,7 +296,6 @@ class _Hqxdecoderengine:
while 1: while 1:
try: try:
decdatacur, self.eof = binascii.a2b_hqx(data) decdatacur, self.eof = binascii.a2b_hqx(data)
if self.eof: print 'EOF'
break break
except binascii.Incomplete: except binascii.Incomplete:
pass pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment