[squeak-dev] The Inbox: Collections-ul.844.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Fri Jul 19 05:43:03 UTC 2019


Hi Levente,

could you expand the method comment to refer to #at:ifAbsent: and the [nil] example?  Write it in a way that programmers do not end up using #atOrNil: + ifNil: without knowing better. :-)

Best,
Marcel
Am 19.07.2019 01:04:33 schrieb Chris Muller <ma.chris.m at gmail.com>:
Wow, +1 then. Amazing how you're able find this kind of performance
improvement in as low-level a method as String>>#at:ifAbsent:.

- Chris

On Thu, Jul 18, 2019 at 5:58 PM Levente Uzonyi wrote:
>
> On Thu, 18 Jul 2019, Chris Muller wrote:
>
> > Is it faster even if the argument to ifAbsent: is simply "nil" instead of "[nil]"?
>
> More than 4x faster when the index is valid and more than twice as fast
> when the index is not valid.
>
> Levente
>
> >
> > On Thu, Jul 18, 2019 at 5:13 PM wrote:
> > Levente Uzonyi uploaded a new version of Collections to project The Inbox:
> > http://source.squeak.org/inbox/Collections-ul.844.mcz
> >
> > ==================== Summary ====================
> >
> > Name: Collections-ul.844
> > Author: ul
> > Time: 19 July 2019, 12:08:51.94435 am
> > UUID: df5ebfa9-4ebf-4505-8031-afd892a1061c
> > Ancestors: Collections-mt.843
> >
> > - added String >> #atOrNil: which uses primitive 63 and returns either the character at the given index or nil when the primtiive fails. This is a faster alternative to #at:ifAbsent: when the absent block would
> > yield nil.
> >
> > =============== Diff against Collections-mt.843 ===============
> >
> > Item was added:
> > + ----- Method: String>>atOrNil: (in category 'as yet unclassified') -----
> > + atOrNil: anIndex
> > + "Return the character at anIndex or nil if the index or the argument is not valid."
> > +
> > +
> > + ^nil!
> >
> >
> >
> >

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190719/f0bcf089/attachment.html>


More information about the Squeak-dev mailing list