[squeak-dev] The Trunk: Morphic-ul.538.mcz

commits at source.squeak.org commits at source.squeak.org
Thu May 12 02:52:52 UTC 2011


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

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

Name: Morphic-ul.538
Author: ul
Time: 12 May 2011, 4:44:11.253 am
UUID: a8b91677-c5a2-624c-aa73-dacb6ab3ca1c
Ancestors: Morphic-nice.537

- use #findBinaryIndex:ifNone: instead of a custom binary search in NewParagraph >> #fastFindFirstLineSuchThat:

=============== Diff against Morphic-nice.537 ===============

Item was changed:
  ----- Method: NewParagraph>>fastFindFirstLineSuchThat: (in category 'private') -----
  fastFindFirstLineSuchThat: lineBlock
  	"Perform a binary search of the lines array and return the index
  	of the first element for which lineBlock evaluates as true.
  	This assumes the condition is one that goes from false to true for
  	increasing line numbers (as, eg, yval > somey or start char > somex).
  	If lineBlock is not true for any element, return size+1."
+ 	
+ 	^lines
+ 		findBinaryIndex: [ :each | 
+ 			(lineBlock value: each)
+ 				ifTrue: [ -1 ]
+ 				ifFalse: [ 1 ] ]
+ 		ifNone: [ :lower :upper | upper ]!
- 	| index low high |
- 	low := 1.
- 	high := lines size.
- 	[low > high]
- 		whileFalse: 
- 			[index := high + low // 2.
- 			(lineBlock value: (lines at: index))
- 				ifTrue: [high := index - 1]
- 				ifFalse: [low := index + 1]].
- 	^ low!




More information about the Squeak-dev mailing list