<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
                                        
                                        
                                            
                                        
                                        
                                        Hi Levente.<div><br><div>> <span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Instead of overriding #isEmpty in all weak subclasses, we can handle</span><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"> </span></div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">it in HashedCollection if we want to:</span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">I think I will do that in 5.3rc2 because I will also add #isEmpty tests for those weak collections, which would fail otherwise. I hope that's okay with everybody. That bug in #isEmpty is a regression since (about) Squeak 5.1.</span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Here is a benchmark of #isEmpty for Smalltalk's bindings dictionary:</span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><div style=""><span style="font-family: Arial, Helvetica, sans-serif"><span style="font-size: 13px">BEFORE</span></span></div><div style=""><span style="font-family: Arial, Helvetica, sans-serif"><span style="font-size: 13px">'134,000,000 per second. 7.47 nanoseconds per run. 0 % GC time.'</span></span></div><div style=""><span style="font-family: Arial, Helvetica, sans-serif"><span style="font-size: 13px">AFTER</span></span></div><div style=""><span style="font-family: Arial, Helvetica, sans-serif"><span style="font-size: 13px">'51,700,000 per second. 19.3 nanoseconds per run. 0 % GC time.'</span></span></div><div style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></div></div><div style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Best,<br></div><div style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Marcel</div><div class="mb_sig"></div>
                                        
                                        <blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
                        <p style="color: #AAAAAA; margin-top: 10px;">Am 26.02.2020 15:44:57 schrieb Levente Uzonyi <leves@caesar.elte.hu>:</p><div style="font-family:Arial,Helvetica,sans-serif">Hi Marcel,<br><br>On Wed, 26 Feb 2020, Marcel Taeumel wrote:<br><br>> Hi Levente,<br>> hmm... but WeakSet does also not respond correctly to #isEmpty. Yes, there is a bug with tally calculation as you descrined. However, all weak collections can only support #maybeNotEmpty and never #isEmpty (because of the false case).<br><br>Right, my response is more related to one of the previous emails of yours.<br>But, weak collections can and should respond to #isEmpty by using <br>Collection's implementation.<br>However, due to the way weak references are handled, the response is not <br>entirely reliable. IMO, it's the sender's responsibility to take care of <br>the possibility of the changed state (#isEmpty returns false, but the last <br>element is gone before the next message is processed by the VM).<br>Instead of overriding #isEmpty in all weak subclasses, we can handle <br>it in HashedCollection if we want to:<br><br>isEmpty<br>     "TODO: Add a nice comment here."<br><br>  ^array class isWeak<br>           ifFalse: [ tally = 0 ]<br>                ifTrue: [ super isEmpty ]<br><br><br>Levente<br><br>> <br>> Best,<br>> Marcel<br>><br>>       Am 26.02.2020 14:54:46 schrieb Levente Uzonyi <leves@caesar.elte.hu>:<br>><br>>       Hi Marcel,<br>><br>>       The cause of the problem is that unlike other weak hashed collections,<br>>       WeakIdentityDictionary does not recalculate tally in<br>>       #noCheckNoGrowFillFrom:. And that's a bug, because it lets tally increase<br>>       indefinitely.<br>><br>>       The bug appears now, because before Undeclared became a<br>>       WeakIdentityDictionary, #compact, which is part of what ReleaseBuilder<br>>       does, would recalculate the tally via #noCheckNoGrowFillFrom:.<br>><br>>       So, even for weak hashed collections, tally should never be larger than<br>>       the actual capacity (not #capacity, which currently implemented as array<br>>       size is a misnomer) of the collection.<br>> <br>><br>>       Levente<br>><br>>       On Wed, 26 Feb 2020, marcel.taeumel wrote:<br>><br>>       > Maybe weak collections should never claim to be empty anymore after any<br>>       > element was added to them? I would understand that since repeated calls can<br>>       > return different results.<br>>       ><br>>       > Best,<br>>       > Marcel<br>>       ><br>>       ><br>>       ><br>>       > --<br>>       > Sent from: http://forum.world.st/Squeak-Dev-f45488.html<br>> <br>> <br>><br><br></leves@caesar.elte.hu></div></blockquote></div>