[squeak-dev] The Trunk: Collections-mt.966.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Dec 2 15:06:09 UTC 2021

Marcel Taeumel uploaded a new version of Collections to project The Trunk:

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

Name: Collections-mt.966
Author: mt
Time: 2 December 2021, 4:06:07.345715 pm
UUID: e18db8cb-0b3c-1d48-95f3-f5955e1ea837
Ancestors: Collections-mt.965

New message on Text: add a text attribute to the entire text unless there is a conflict with an existing text attribute. So, automatically compute the ranges that fit.

=============== Diff against Collections-mt.965 ===============

Item was added:
+ ----- Method: Text>>addAttribute:unless: (in category 'emphasis') -----
+ addAttribute: anAttribute unless: aBlock
+ 	"Only add anAttribute when aBlock evaluates to false. Can be used to avoid overwriting existing attributes without knowing exactly where they are. Kind of complements the #dominates: protocol in TextAttribute."
+ 	| offset |
+ 	self flag: #performance. "mt: Can we do this faster?"
+ 	runs copy withIndexDo: [:attrs :index |
+ 		(aBlock cull: attrs cull: index)
+ 			ifFalse: [offset ifNil: [
+ 				offset := index]]
+ 			ifTrue: [offset ifNotNil: [
+ 				self addAttribute: anAttribute from: offset to: index - 1.
+ 				offset := nil]]].
+ 	offset ifNotNil: [
+ 		self addAttribute: anAttribute from: offset to: self size].!

More information about the Squeak-dev mailing list