[squeak-dev] The Inbox: Kernel-ct.1294.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Jan 9 14:42:46 UTC 2020


A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-ct.1294.mcz

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

Name: Kernel-ct.1294
Author: ct
Time: 9 January 2020, 3:42:36.672555 pm
UUID: 7409dcc3-160e-9d44-9712-f266e0f25973
Ancestors: Kernel-nice.1292

Proposal: Add #haltOnceIf: to Object, which combines the strengths of #haltOnce and #haltIf:. Especially useful in performance-critical situations: It HaltOnce is disabled, the condition will not be evaluated at all.

=============== Diff against Kernel-nice.1292 ===============

Item was changed:
  ----- Method: Object>>haltIf: (in category 'debugging') -----
+ haltIf: aCondition
+ 	"This is the typical message to use for inserting breakpoints during debugging. Param can be a block or expression, halt if true.
- haltIf: condition
- 	"This is the typical message to use for inserting breakpoints during 
- 	debugging.  Param can be a block or expression, halt if true.
  	If the Block has one arg, the receiver is bound to that.
+  	If the condition is a selector, we look up in the callchain. Halt if any method's selector equals selector."
-  	If the condition is a selector, we look up in the callchain. Halt if
-       any method's selector equals selector."
- 	| cntxt |
  
+ 	^ (self meetsHaltCondition: aCondition)
+ 		ifTrue: [self halt]!
- 	condition isSymbol ifTrue:[
- 		"only halt if a method with selector symbol is in callchain"
- 		cntxt := thisContext.
- 		[cntxt sender isNil] whileFalse: [
- 			cntxt := cntxt sender. 
- 			(cntxt selector = condition) ifTrue: [Halt signal].
- 			].
- 		^self.
- 	].
- 	(condition isBlock 
- 			ifTrue: [condition cull: self] 
- 			ifFalse: [condition] 
- 	) ifTrue: [
- 		Halt signal
- 	].!

Item was added:
+ ----- Method: Object>>haltOnceIf: (in category 'debugging') -----
+ haltOnceIf: aCondition
+ 	"Check aCondition and halt, unless we have already done it once. See #meetsHaltCondition:."
+ 	
+ 	self haltOnceEnabled ifFalse: [^ self].
+ 	^ (self meetsHaltCondition: aCondition)
+ 		ifTrue: [
+ 			self clearHaltOnce; halt].!

Item was added:
+ ----- Method: Object>>meetsHaltCondition: (in category 'debugging') -----
+ meetsHaltCondition: aCondition
+ 	"If the Block has one arg, the receiver is bound to that.
+  	If the condition is a selector, we look up in the callchain. Halt if any method's selector equals selector."
+ 	
+ 	aCondition isSymbol ifTrue: [ | ctxt |
+ 		"only halt if a method with selector symbol is in callchain"
+ 		ctxt := thisContext.
+ 		[(ctxt := ctxt sender) isNil] whileFalse: [
+ 			(ctxt selector = aCondition) ifTrue: [^ true] ].
+ 		^ false ].
+ 	^ aCondition isBlock 
+ 			ifTrue: [aCondition cull: self] 
+ 			ifFalse: [aCondition value]!



More information about the Squeak-dev mailing list