aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--FuseArchive/ChunkBuffer.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/FuseArchive/ChunkBuffer.py b/FuseArchive/ChunkBuffer.py
index 89d468e..575f5aa 100644
--- a/FuseArchive/ChunkBuffer.py
+++ b/FuseArchive/ChunkBuffer.py
@@ -5,11 +5,14 @@ import logging
class ChunkBuffer:
def __init__( self, data = '' ):
logging.debug( "Creating chunkbuffer: %s" % data )
+ self.l = len( data )
self.chunk = [ data ]
def append( self, s ):
+ self.l += len( s )
self.chunk.append( s )
+ # Note: replace doesn't effect length so we don't update it
def replace( self, buf, start, end ):
# We make a string of our chunk, then create a new list of the 3
# strings, the start, new chunk, and remaining chunk
@@ -18,17 +21,11 @@ class ChunkBuffer:
self.chunk = [ s[ :start ], buf[ :l ], s[ end: ] ]
def length( self ):
- if len( self.chunk ) > 5:
- self._simplify()
-
- l = 0;
- for c in self.chunk:
- l += len( c )
-
- return l
+ return self.l
def truncate( self, l ):
s = ''.join( self.chunk )
+ self.l = l
self.chunk = [ s[ :l ] ]
def _simplify( self ):