WriteStream.st
branchjv
changeset 18066 89d51443ba6f
parent 18057 8da7c39a6322
parent 15354 21ebb380b376
child 18071 009cf668b0ed
--- a/WriteStream.st	Sun Jun 09 00:49:37 2013 +0100
+++ b/WriteStream.st	Mon Jun 10 17:32:35 2013 +0100
@@ -120,17 +120,17 @@
 
     |lastIndex|
 
-    lastIndex := position - ZeroPosition.
+    lastIndex := position.
     collection size == lastIndex ifFalse:[
-	collection isFixedSize ifTrue:[
-	    "
-	     grow is expensive - return a copy.
-	     (is this what users of writeStream expect ?)
-	    "
-	    collection := collection copyFrom:1 to:lastIndex
-	] ifFalse:[
-	    collection grow:lastIndex
-	]
+        collection isFixedSize ifTrue:[
+            "
+             grow is expensive - return a copy.
+             (is this what users of writeStream expect ?)
+            "
+            collection := collection copyFrom:1 to:lastIndex
+        ] ifFalse:[
+            collection grow:lastIndex
+        ]
     ].
     ^ collection
 
@@ -143,7 +143,7 @@
 
     |position1Based|
 
-    position1Based := position - ZeroPosition + 1.
+    position1Based := position + 1.
     ^ collection at:(position1Based - 1).
 
     "
@@ -165,7 +165,7 @@
 
     |position1Based|
 
-    position1Based := position - ZeroPosition + 1.
+    position1Based := position + 1.
     ^ collection copyFrom:(position1Based - n) to:(position1Based - 1).
 
     "
@@ -200,7 +200,7 @@
     "redefined to allow positioning past the readLimit"
 
     ((index0Based > collection size) or:[index0Based < 0]) ifTrue: [^ self positionError].
-    position := index0Based + ZeroPosition
+    position := index0Based
 ! !
 
 !WriteStream methodsFor:'private'!
@@ -273,7 +273,7 @@
 size
     "return the current size"
 
-    ^ position - ZeroPosition
+    ^ position
 ! !
 
 !WriteStream methodsFor:'reading'!
@@ -295,7 +295,7 @@
 isEmpty
     "return true, if the contents of the stream is empty"
 
-    ^ self position0Based == ZeroPosition
+    ^ self position0Based == 0
 
     "Created: 14.10.1997 / 20:44:37 / cg"
 ! !
@@ -314,7 +314,7 @@
         ^ self.
     ].
 
-    position1Based := position - ZeroPosition + 1.
+    position1Based := position + 1.
     final := position1Based + count - 1.
     (final > collection size) ifTrue:[
         self growCollection:final
@@ -325,7 +325,7 @@
     ].
     position1Based := position1Based + count.
     (position1Based > readLimit) ifTrue:[readLimit := position1Based - 1].
-    position := position1Based - 1 + ZeroPosition.
+    position := position1Based - 1.
     "/ ^ anObject -- return self
 !
 
@@ -365,7 +365,7 @@
     if (__isNonNilObject(coll) && __isSmallInteger(p)) {
         pos = __intVal(p);
         /* make 1-based */
-        pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
+        pos = pos + 1;
         wL = __INST(writeLimit);
 
         if ((wL == nil)
@@ -423,10 +423,10 @@
 #endif
 %}.
     (writeLimit isNil
-    or:[(position + 1 - ZeroPosition) <= writeLimit]) ifTrue:[
-        ((position + 1 - ZeroPosition) > collection size) ifTrue:[self growCollection].
-        collection at:(position + 1 - ZeroPosition) put:anObject.
-        ((position + 1 - ZeroPosition) > readLimit) ifTrue:[readLimit := (position + 1 - ZeroPosition)].
+    or:[(position + 1) <= writeLimit]) ifTrue:[
+        (position >= collection size) ifTrue:[self growCollection].
+        collection at:(position + 1) put:anObject.
+        (position >= readLimit) ifTrue:[readLimit := (position + 1)].
         position := position + 1.
     ] ifFalse:[
         WriteError raiseErrorString:'write beyond writeLimit'
@@ -450,7 +450,7 @@
         ^ self.
     ].
 
-    position1Based := position - ZeroPosition + 1.
+    position1Based := position + 1.
 
     nMore := aCollection size.
     nMore == 0 ifTrue:[
@@ -477,7 +477,7 @@
 
     position1Based := position1Based + nMore.
     (position1Based > readLimit) ifTrue:[readLimit := position1Based - 1].
-    position := position1Based - 1 + ZeroPosition.
+    position := position1Based - 1.
     "/ ^ aCollection -- self
 
     "Modified: / 04-09-2011 / 20:03:32 / cg"
@@ -494,7 +494,7 @@
         ^ super nextPutAll:aCollection startingAt:pos1 to:pos2
     ].
 
-    position1Based := position - ZeroPosition + 1.
+    position1Based := position + 1.
     nMore := pos2 - pos1 + 1.
     final := position1Based + nMore - 1.
     (writeLimit notNil
@@ -513,7 +513,7 @@
 
     position1Based := position1Based + nMore.
     (position1Based > readLimit) ifTrue:[readLimit := position1Based - 1].
-    position := position1Based - 1 + ZeroPosition.
+    position := position1Based - 1.
     "/ ^ aCollection -- return self
 
     "
@@ -632,10 +632,10 @@
 !WriteStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/WriteStream.st,v 1.76 2013-04-26 14:11:10 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/WriteStream.st,v 1.78 2013-06-03 18:39:07 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/WriteStream.st,v 1.76 2013-04-26 14:11:10 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/WriteStream.st,v 1.78 2013-06-03 18:39:07 cg Exp $'
 ! !