<div dir="ltr">Be sure to load Collections-ul.873 first. When I tried to load this one first directly, my image locked.<div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 5, 2020 at 9:47 AM <<a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Levente Uzonyi uploaded a new version of Collections to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Collections-ul.874.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/inbox/Collections-ul.874.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Collections-ul.874<br>
Author: ul<br>
Time: 5 February 2020, 4:40:30.240914 pm<br>
UUID: de45f7ed-0176-48ed-b7d5-3811cbc0fcb9<br>
Ancestors: Collections-ul.873<br>
<br>
- remove cruft and migration code from HashedCollection class >> #goodPrimeAtLeast:<br>
<br>
=============== Diff against Collections-ul.873 ===============<br>
<br>
Item was changed:<br>
----- Method: HashedCollection class>>goodPrimeAtLeast: (in category 'sizing') -----<br>
goodPrimeAtLeast: lowerLimit<br>
"Answer the smallest good prime >= lowerlimit.<br>
If lowerLimit is larger than the largest known good prime, just make it odd.<br>
Use linear search, and exponential search to speed up cases when lowerLimit is small (<2500 and <100000, respectively).<br>
Assume that there are goodPrimes greater than 100000."<br>
<br>
| highIndex midIndex lowIndex prime |<br>
- lowerLimit <= 7 ifTrue: [<br>
- lowerLimit <= 3 ifTrue: [ ^3 ].<br>
- lowerLimit <= 5 ifTrue: [ ^5 ].<br>
- ^7 ].<br>
- GoodPrimes ifNil: [ "migration only"<br>
- self initializeGoodPrimes ].<br>
lowerLimit < 2500 ifTrue: [<br>
"Use linear search when the limit is small. The boundary is based on measurements."<br>
+ highIndex := 1.<br>
- highIndex := 4. "skip 3 5 and 7"<br>
[ (GoodPrimes at: highIndex) < lowerLimit ] whileTrue: [<br>
highIndex := highIndex + 1 ].<br>
^GoodPrimes at: highIndex ].<br>
lowerLimit < 100000 <br>
ifTrue: [<br>
"Use exponential search when the limit is not too large. The boundary is based on measurements."<br>
highIndex := 1.<br>
[ (GoodPrimes at: highIndex) < lowerLimit ] whileTrue: [<br>
highIndex := highIndex * 2 ].<br>
lowIndex := highIndex // 2 + 1. "highIndex // 2 was smaller than lowerLimit" ]<br>
ifFalse: [<br>
"Regular binary search."<br>
lowIndex := 1.<br>
highIndex := GoodPrimes size.<br>
"Check whether the largest prime would fit"<br>
(GoodPrimes at: highIndex) < lowerLimit ifTrue: [<br>
^lowerLimit bitOr: 1 ]. ].<br>
[ highIndex - lowIndex <= 1 ] whileFalse: [<br>
midIndex := highIndex + lowIndex // 2.<br>
prime := GoodPrimes at: midIndex.<br>
lowerLimit < prime<br>
ifTrue: [ highIndex := midIndex ]<br>
ifFalse: [<br>
lowerLimit > prime<br>
ifTrue: [ lowIndex := midIndex ]<br>
ifFalse: [ ^prime ] ] ].<br>
(GoodPrimes at: lowIndex) >= lowerLimit ifTrue: [ ^GoodPrimes at: lowIndex ].<br>
^GoodPrimes at: highIndex!<br>
<br>
<br>
</blockquote></div>