[Pkg] The Trunk: Kernel-ul.1156.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Mar 5 19:39:48 UTC 2018


Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.1156.mcz

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

Name: Kernel-ul.1156
Author: ul
Time: 5 March 2018, 8:39:27.154484 pm
UUID: fd37b9ca-0eff-41f7-aa23-a46a2223d482
Ancestors: Kernel-eem.1155

Changed #isCompiledBlock to #isCompiledCode in some implementations of #hasLiteralSuchThat: to avoid DNUs when the literal is not an Array or a CompiledBlock (e.g. string).

Improved Integer >> #isPrime's performance in 64-bit images

=============== Diff against Kernel-eem.1155 ===============

Item was changed:
  ----- Method: CompiledBlock>>hasLiteralSuchThat: (in category 'literals') -----
  hasLiteralSuchThat: litBlock
  	"Answer true if litBlock returns true for any literal in this method, even if embedded in array structure."
  	2 to: self numLiterals do:
  		[:index | | lit |
  		lit := self objectAt: index.
  		((litBlock value: lit)
+ 		or: [(lit isArray or: [lit isCompiledCode]) and: [lit hasLiteralSuchThat: litBlock]]) ifTrue:
- 		or: [(lit isArray or: [lit isCompiledBlock]) and: [lit hasLiteralSuchThat: litBlock]]) ifTrue:
  			[^true]].
  	^false!

Item was changed:
  ----- Method: CompiledMethod>>hasLiteralSuchThat: (in category 'literals') -----
  hasLiteralSuchThat: litBlock
  	"Answer true if litBlock returns true for any literal in this method, even if embedded in array structure."
  	(self penultimateLiteral isMethodProperties
  	 and: [self penultimateLiteral hasLiteralSuchThat: litBlock]) ifTrue:
  		[^true].
  	2 to: self numLiterals + 1 do:
  		[:index | | lit |
  		lit := self objectAt: index.
  		((litBlock value: lit)
+ 		or: [(lit isArray or: [lit isCompiledCode]) and: [lit hasLiteralSuchThat: litBlock]]) ifTrue:
- 		or: [(lit isArray or: [lit isCompiledBlock]) and: [lit hasLiteralSuchThat: litBlock]]) ifTrue:
  			[^true]].
  	^false!

Item was changed:
  ----- Method: Integer>>isPrime (in category 'testing') -----
  isPrime
  	"Answer true if the receiver is a prime number. See isProbablyPrime for a probabilistic
  	implementation that is much faster for large integers, and that is correct to an extremely
  	high statistical level of confidence (effectively deterministic)."
  	
  	self <= 1 ifTrue: [ ^false ].
  	self even ifTrue: [ ^self = 2].
+ 	self <= 1073741823 ifFalse: [ "1 << 30 - 1. For numbers larger than this, the calculation takes longer than #isProbablyPrime when the receiver is a prime. The absolue turning point is about at 1 << 35 - 1."
+ 		^self isProbablyPrime ].
  	3 to: self sqrtFloor by: 2 do: [ :each |
  		self \\ each = 0 ifTrue: [ ^false ] ].
  	^true!



More information about the Packages mailing list