The Trunk: Collections-ul.875.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-ul.875.mcz

commits-2
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.875.mcz

==================== Summary ====================

Name: Collections-ul.875
Author: ul
Time: 17 February 2020, 12:18:54.69743 am
UUID: e8d8fa4d-f205-4861-ac70-46989463beed
Ancestors: Collections-ul.874

- remove cruft and migration code from HashedCollection class >> #goodPrimeAtLeast:

=============== Diff against Collections-ul.874 ===============

Item was changed:
  ----- Method: HashedCollection class>>goodPrimeAtLeast: (in category 'sizing') -----
  goodPrimeAtLeast: lowerLimit
  "Answer the smallest good prime >= lowerlimit.
  If lowerLimit is larger than the largest known good prime, just make it odd.
  Use linear search, and exponential search to speed up cases when lowerLimit is small (<2500 and <100000, respectively).
  Assume that there are goodPrimes greater than 100000."
 
  | highIndex midIndex lowIndex prime |
- lowerLimit <= 7 ifTrue: [
- lowerLimit <= 3 ifTrue: [ ^3 ].
- lowerLimit <= 5 ifTrue: [ ^5 ].
- ^7 ].
- GoodPrimes ifNil: [ "migration only"
- self initializeGoodPrimes ].
  lowerLimit < 2500 ifTrue: [
  "Use linear search when the limit is small. The boundary is based on measurements."
+ highIndex := 1.
- highIndex := 4. "skip 3 5 and 7"
  [ (GoodPrimes at: highIndex) < lowerLimit ] whileTrue: [
  highIndex := highIndex + 1 ].
  ^GoodPrimes at: highIndex ].
  lowerLimit < 100000
  ifTrue: [
  "Use exponential search when the limit is not too large. The boundary is based on measurements."
  highIndex := 1.
  [ (GoodPrimes at: highIndex) < lowerLimit ] whileTrue: [
  highIndex := highIndex * 2 ].
  lowIndex := highIndex // 2 + 1. "highIndex // 2 was smaller than lowerLimit" ]
  ifFalse: [
  "Regular binary search."
  lowIndex := 1.
  highIndex := GoodPrimes size.
  "Check whether the largest prime would fit"
  (GoodPrimes at: highIndex) < lowerLimit ifTrue: [
  ^lowerLimit bitOr: 1 ]. ].
  [ highIndex - lowIndex <= 1 ] whileFalse: [
  midIndex := highIndex + lowIndex // 2.
  prime := GoodPrimes at: midIndex.
  lowerLimit < prime
  ifTrue: [ highIndex := midIndex ]
  ifFalse: [
  lowerLimit > prime
  ifTrue: [ lowIndex := midIndex ]
  ifFalse: [ ^prime ] ] ].
  (GoodPrimes at: lowIndex) >= lowerLimit ifTrue: [ ^GoodPrimes at: lowIndex ].
  ^GoodPrimes at: highIndex!