Hi Marcel,

    hint: look at the bytecode. The bytecode compiler inlined most blocks into ifTrue:ifFalse: et al hence this

#() isEmpty ifTrue: ['hallo'] ifFalse: ['squeak']

produces no closures, compiling to conditional jump bytecodes.
Whereas this
 
#() ifEmpty: ['hallo'] ifNotEmpty: ['squeak']

produces two closures as arguments.

Apologies about the text size change

_,,,^..^,,,_ (phone)

On Sep 19, 2023, at 4:14 AM, Marcel Taeumel via Squeak-dev <squeak-dev@lists.squeakfoundation.org> wrote:


Hi all --

[ #() isEmpty ifTrue: ['hallo'] ifFalse: ['squeak'] ] bench 
'127,000,000 per second. 7.85 nanoseconds per run. 0 % GC time.' 
[ #() ifEmpty: ['hallo'] ifNotEmpty: ['squeak'] ] bench 
7,580,000 per second. 132 nanoseconds per run. 78.0088 % GC time.' 

Why is that? :-) Why is there an extra GC?

Here is the current implementation of #ifEmpty:ifNotEmpty:

ifEmpty: emptyBlock ifNotEmpty: notEmptyBlock
    self isEmpty ifTrue: [^ emptyBlock value].
    
^ notEmptyBlock cull: self

Best,
Marcel