#BUGFIX by cg
authorClaus Gittinger <cg@exept.de>
Wed, 27 Mar 2019 21:09:11 +0100
changeset 24000 77187a60035a
parent 23999 ced7327500f6
child 24001 d0293bbca0af
#BUGFIX by cg class: EncodedStream keeping the position is way too slow - therefore disabled; users of encoded streams (utf8 encoded) need to get/set the position themself, when required. class definition changed: #next #skip:
EncodedStream.st
--- a/EncodedStream.st	Wed Mar 27 20:47:11 2019 +0100
+++ b/EncodedStream.st	Wed Mar 27 21:09:11 2019 +0100
@@ -16,7 +16,7 @@
 "{ NameSpace: Smalltalk }"
 
 PeekableStream subclass:#EncodedStream
-	instanceVariableNames:'encoder stream peekChar positionOfStreamBeforeLast'
+	instanceVariableNames:'encoder stream peekChar'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Collections-Text-Encodings'
@@ -312,7 +312,6 @@
         peekChar := nil.
         ^ p.
     ].
-    positionOfStreamBeforeLast := stream position.
     ^ encoder readNextCharacterFrom:stream
 
     "Created: / 14-06-2005 / 17:01:39 / janfrog"
@@ -453,16 +452,12 @@
 !
 
 skip:nrToSkip
-    "sigh: this positions the underlying stream, ignoring any encodings"
-
-    "/ can only skip backward by one single character
-    nrToSkip == -1 ifTrue:[
-        stream position:positionOfStreamBeforeLast.
-        peekChar := nil.
+    "/ can only skip forward
+    nrToSkip < 0 ifTrue:[
+        self proceedableError:'cannot position backwards'.
         ^ self.
     ].
-    self breakPoint:#cg info:'possibly wrong positioning'.
-    stream position:(stream position + nrToSkip).
+    nrToSkip timesRepeat:[self next]
 !
 
 sync