<br><br><div class="gmail_quote">On Fri, Nov 27, 2009 at 9:03 AM, David T. Lewis <span dir="ltr">&lt;<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
On Thu, Nov 26, 2009 at 03:10:52PM +0100, Henrik Johansen wrote:<br>
&gt;<br>
</div><div><div></div><div class="h5">&gt; Interpreter &gt;&gt; primitiveNextPut:<br>
&gt;  limit := self fetchInteger: StreamReadLimitIndex ofObject: stream.<br>
&gt;       atIx := (array bitAnd: AtCacheMask) + AtPutBase.<br>
&gt;       (index &lt; limit and: [(atCache at: atIx+AtCacheOop) = array])<br>
&gt;<br>
&gt; so basically, it needs ReadLimit to be &gt; 0. (Which is only true for (Read)WriteStreams if created with on:from:to:).<br>
&gt;<br>
&gt; Changing the first line to<br>
&gt;  limit := self fetchInteger: StreamWriteLimitIndex ofObject: stream.<br>
&gt;<br>
&gt; and the primitive now works.<br>
&gt; ws := WriteStream on: (String new: 500000).<br>
&gt; [1 to: 500000 do: [:ix | ws nextPut: $a]] timeToRun<br>
&gt;<br>
&gt; before: 130<br>
&gt;  after: 33<br>
&gt;<br>
&gt; Inserted a counter after the prim call, for the loop above it was always &gt;= 500000, with fix it&#39;s &gt;=1.<br>
<br>
</div></div>Can anyone comment as to whether the above fix is correct? It looks right<br>
to me, but it would be good if someone familiar with #primitiveNextPut<br>
and the AtCache could review it.<br></blockquote><div><br></div><div>The fix is correct.  c.f. the body of WriteStream&gt;&gt;nextPut:.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I note that this primitive has not changed since 1998, so this would<br>
rate as a really excellent bug catch!<br>
<div class="im"><br>
  <a href="http://bugs.squeak.org/view.php?id=7421" target="_blank">http://bugs.squeak.org/view.php?id=7421</a><br>
<br>
</div>Thanks,<br>
Dave<br>
<br>
</blockquote></div><br>