Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.242.mcz ==================== Summary ==================== Name: Collections-ul.242 Author: ul Time: 9 December 2009, 10:59:18 am UUID: 9524ed86-4a97-f74e-9e05-bdd35c6a5f64 Ancestors: Collections-nice.241, Collections-ul.241 - fix: Character >> #digitValue shadowed instance variable: value - fix: Character >> #storeBinaryOn: didn't work with non-octet characters - faster methods in String: #convertFromWithConverter:, #convertToWithConverter: and #skipDelimiters:startingAt: =============== Diff against Collections-nice.241 =============== Item was changed: ----- Method: String>>convertFromWithConverter: (in category 'converting') ----- convertFromWithConverter: converter - | readStream writeStream c | - readStream := self readStream. - writeStream := String new writeStream. converter ifNil: [^ self]. + ^String new: self size streamContents: [ :stream | + | readStream character | + readStream := self readStream. + [ (character := converter nextFromStream: readStream) == nil ] + whileFalse: [ stream nextPut: character ] ] + - [readStream atEnd] whileFalse: [ - c := converter nextFromStream: readStream. - c ifNotNil: [writeStream nextPut: c] ifNil: [^ writeStream contents] - ]. - ^ writeStream contents ! Item was changed: ----- Method: Character>>digitValue (in category 'accessing') ----- digitValue "Answer 0-9 if the receiver is $0-$9, 10-35 if it is $A-$Z, and < 0 otherwise. This is used to parse literal numbers of radix 2-36." + + | digitValue | + (digitValue := ('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' indexOf: self) - 1) >= 0 + ifTrue: [ ^digitValue ]. - | value | - - value := ('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' indexOf: self) - 1. - value >= 0 ifTrue: [^value]. ^ (EncodedCharSet charsetAt: self leadingChar) digitValue: self. ! Item was changed: ----- Method: String>>skipDelimiters:startingAt: (in category 'accessing') ----- skipDelimiters: delimiters startingAt: start "Answer the index of the character within the receiver, starting at start, that does NOT match one of the delimiters. If the receiver does not contain any of the delimiters, answer size + 1. Assumes the delimiters to be a non-empty string." start to: self size do: [:i | + (delimiters includes: (self at: i)) ifFalse: [ ^i ] ]. + ^self size + 1! - delimiters detect: [:delim | delim = (self at: i)] - ifNone: [^ i]]. - ^ self size + 1! Item was changed: ----- Method: Character>>storeBinaryOn: (in category 'printing') ----- storeBinaryOn: aStream "Store the receiver on a binary (file) stream" + value < 256 + ifTrue: [ aStream basicNextPut: self ] + ifFalse: [ aStream nextInt32Put: value ]! - ifTrue:[aStream basicNextPut: self] - ifFalse:[Stream nextInt32Put: value].! Item was changed: ----- Method: String>>convertToWithConverter: (in category 'converting') ----- convertToWithConverter: converter + converter ifNil: [ ^self ]. + ^String new: self size streamContents: [ :stream | + | character | + 1 to: self size do: [ :index | + converter + nextPut: (self at: index) + toStream: stream ]. + converter emitSequenceToResetStateIfNeededOn: stream ]! - | readStream writeStream | - readStream := self readStream. - writeStream := String new writeStream. - converter ifNil: [^ self]. - [readStream atEnd] whileFalse: [ - converter nextPut: readStream next toStream: writeStream - ]. - converter emitSequenceToResetStateIfNeededOn: writeStream. - ^ writeStream contents. - ! |
Free forum by Nabble | Edit this page |