help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] [PATCH 1/2] streams: Fix the ConcatenatedStream>>#c


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] [PATCH 1/2] streams: Fix the ConcatenatedStream>>#copyFrom:to: implementation
Date: Tue, 09 Oct 2012 19:15:55 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1

Il 09/10/2012 16:43, Holger Hans Peter Freyther ha scritto:
>> > -  [(s := streams first) atEnd] whileTrue: 
>> > -          [streams size = 1 ifTrue: [^nil].
>> > -          lastStart := startPos.
>> > +        "This is somewhat performance-sensitive, so avoid testing for an
>> > +         empty collection."
>> > +  [(s := streams at: 1) atEnd] whileTrue: 
>> > +          [lastStart := startPos.
>> >            startPos := startPos + curPos.
>> >            curPos := 0.
>> > +                streams size = 1 ifTrue: [last := streams first. ^nil].
> I don't see why it is failing but maybe the test helps.

Yes, this fixes it:

diff --git a/kernel/StreamOps.st b/kernel/StreamOps.st
index 63bea8a..54f82af 100644
--- a/kernel/StreamOps.st
+++ b/kernel/StreamOps.st
@@ -81,9 +81,10 @@ Stream subclass: ConcatenatedStream [
         "This is somewhat performance-sensitive, so avoid testing for an
          empty collection."
        [(s := streams at: 1) atEnd] whileTrue: 
-               [lastStart := startPos.
-               startPos := startPos + curPos.
-               curPos := 0.
+               [curPos > 0 ifTrue: [
+                    lastStart := startPos.
+                   startPos := startPos + curPos.
+                   curPos := 0].
                 streams size = 1 ifTrue: [last := streams first. ^nil].
                last := streams removeFirst].
        ^s

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]