<div dir="ltr"><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 3, 2018 at 10:09 PM, karl ramberg <span dir="ltr"><<a href="mailto:karlramberg@gmail.com" target="_blank">karlramberg@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I'm all for faster code in the standard library.<div>One could leave the old version in the comment as an example for other ways of writing it.</div><div><br></div></div></blockquote><div>

<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Which he already did.</span><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">Why complain about it then :-(</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">Best,</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">Karl</div><br class="gmail-Apple-interchange-newline">

 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div><div>Best,</div><div>Karl</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 3, 2018 at 7:51 PM, Chris Cunningham <span dir="ltr"><<a href="mailto:cunningham.cb@gmail.com" target="_blank">cunningham.cb@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Thu, May 3, 2018 at 10:34 AM, Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Thu, May 3, 2018 at 10:12 AM, Chris Muller <span dir="ltr"><<a href="mailto:asqueaker@gmail.com" target="_blank">asqueaker@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">+1.  Not only that, why the call to #basicSize and #basicAt:.  Really?<br>
<br>
It's like...  not even Smalltalk anymore...   :(<br></blockquote><div><br></div></span><div>What?  This is a workhorse method, and you want to create a block, and apply the block to each element, and convert each element from a character to an integer, when basicAt: yields (and has always yielded) integers in strings?  You think that one line with a block and a high-level iterator is so much better than a two line with a simpler inner loop?</div><div> </div><div><div>| strings nothing allSatisfy basicAt |</div><div>strings := String allSubInstances.</div><div>strings := strings, strings, strings, strings, strings.</div><div>nothing := [:s|].</div><div>allSatisfy := [:s| s isAsciiStringWithAllSatisfy].</div><div>basicAt := [:s| s isAsciiStringWithBasicAt].</div><div>Smalltalk garbageCollect.</div><div>1 to: 2 do:</div><div><span class="m_-2419342603620482340m_-4146867987906159694m_-1230378789376810188gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>[:ign| times := { nothing. allSatisfy. basicAt } collect: [:block| [strings do: block] timeToRun]].</div><div>(times second - times first / (times third - times first) asFloat) roundTo: 0.1</div><div><br></div><div>Answers range from 5.1 to 5.7 on 64-bits Mac OS X.</div></div><div><br></div><div>You really want that elegance for something that is 5 times slower but one line shorter?  I did this because I saw Patrick inline isAsciiString in mail message processing, and I thought a) his method would read better if it used isAsciiString, and b) isAsciiString can be implemented much better without affecting clients, so I went ahead.  Part of the beauty of Smalltalk is that clients are insulated from implementation so that implementations can be improved.  Since when has that not been a part of Smalltalk?</div><div><div class="m_-2419342603620482340m_-4146867987906159694h5"><div><br></div></div></div></div></div></div></blockquote></span><div>While I understand (and like) the idea of having nice, clean, elegant methods everywhere in Squeak, I also would like it to be super fast.  I think Eliot's change is a nice example straddling that line - note the elegant way, and then show (and implement) a fast way to do the same thing still just using Smalltalk.</div><div><br></div><div>Not to mention that he actually commented the method with what it should do.</div><div><br></div><div>-cbc</div></div></div></div>
<br><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>