[FIX][ENH] Two fixes for #isEmpty
Andres Valloud
avalloud at entrypoint.com
Thu Apr 13 01:45:22 UTC 2000
Hi.
Here's a better version of my previous two fixes for #isEmpty. It
includes a reimplementation of String>>keywords that takes ~2/3 the time
of the previous one to execute.
Andres.
-------------- next part --------------
'From Squeak2.8alpha of 12 April 2000 [latest update: #1974] on 12 April 2000 at 6:39:03 pm'!
!ParagraphEditor methodsFor: 'typing support' stamp: 'SqR 4/12/2000 18:29'!
insertTypeAhead: typeAhead
typeAhead position = 0 ifFalse:
[self zapSelectionWith:
(Text string: typeAhead contents emphasis: emphasisHere).
typeAhead reset.
startBlock _ stopBlock copy]! !
!PositionableStream methodsFor: 'testing' stamp: 'SqR!!!!!!!! 4/6/2000 14:34'!
isEmpty
"Answer whether the receiver's contents has no elements."
"This method is VERY MISLEADING and should not be used at all!!
SqR!! 4/6/2000 14:34"
^position = 0! !
!String methodsFor: 'converting' stamp: 'SqR 4/12/2000 18:35'!
keywords
"Answer an array of the keywords that compose the receiver.
Reimplemented to clean up PositionableStream>>isEmpty.
SqR 4/12/2000 18:35"
| answer last selfSize |
answer _ OrderedCollection new: 10.
selfSize _ self size. last _ 0.
1 to: selfSize do:
[:each |
(self at: each) = $: ifTrue:
[
answer add: (self copyFrom: last + 1 to: each).
last _ each.
].
].
last = selfSize ifFalse: [answer add: (self copyFrom: last + 1 to: selfSize)].
^answer asArray! !
More information about the Squeak-dev
mailing list
|