less memory need for hexDump
authorClaus Gittinger <cg@exept.de>
Tue, 15 Aug 2000 16:24:18 +0200
changeset 2701 78171ebe64f5
parent 2700 854f2402bc08
child 2702 4d64b70cf90c
less memory need for hexDump
FileBrowser.st
--- a/FileBrowser.st	Tue Aug 15 16:20:32 2000 +0200
+++ b/FileBrowser.st	Tue Aug 15 16:24:18 2000 +0200
@@ -2388,7 +2388,7 @@
 
     self withReadCursorDo:[
         |fileName f stream data offs 
-         addrDigits col line asciiLine lines|
+         addrDigits col line lineStream asciiLineStream lines|
 
         fileName := self getSelectedFileName.
         fileName notNil ifTrue:[
@@ -2421,33 +2421,41 @@
 
             addrDigits := ((f fileSize + 1) log:16) truncated + 1.
 
-            line := (offs hexPrintString:addrDigits) , ': '.
-            asciiLine := ''.
+            lineStream := '' writeStream.
+            asciiLineStream := '' writeStream.
+
+            lineStream nextPutAll:(offs hexPrintString:addrDigits).
+            lineStream nextPutAll:': '.
 
             data do:[:byte |
-                line := line , (byte hexPrintString:2).
+                lineStream nextPutAll:(byte hexPrintString:2).
                 (byte between:32 and:127) ifTrue:[
-                    asciiLine := asciiLine copyWith:(Character value:byte)
+                    asciiLineStream nextPut:(Character value:byte)
                 ] ifFalse:[
-                    asciiLine := asciiLine , '.'
+                    asciiLineStream nextPut:$.
                 ].
 
                 offs := offs + 1.
                 col := col + 1.
                 col > 16 ifTrue:[
-                    lines add:(line , '        ' , asciiLine).
+                    lineStream nextPutAll:'        '.
+                    lineStream nextPutAll:asciiLineStream contents.
+                    lines add:(lineStream contents).
                     (offs bitAnd:16rFF) == 0 ifTrue:[
                         lines add:nil
                     ].
-                    line := (offs hexPrintString:addrDigits) , ': '.
-                    asciiLine := ''.
+                    lineStream reset.
+                    asciiLineStream reset.
+
+                    lineStream nextPutAll:(offs hexPrintString:addrDigits).
+                    lineStream nextPutAll:': '.
                     col := 1.
                 ] ifFalse:[
-                    line := line , ' '
+                    lineStream space
                 ]
             ].
-            line := line paddedTo:(3*16 + addrDigits + 1).
-            lines add:(line , '        ' , asciiLine).
+            line := lineStream contents paddedTo:(3*16 + addrDigits + 1).
+            lines add:(line , '        ' , asciiLineStream contents).
             self show:lines.
         ]
     ]
@@ -7101,5 +7109,5 @@
 !FileBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.373 2000-08-04 12:45:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.374 2000-08-15 14:24:18 cg Exp $'
 ! !