The Trunk: Files-nice.49.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Files-nice.49.mcz

commits-2
Nicolas Cellier uploaded a new version of Files to project The Trunk:
http://source.squeak.org/trunk/Files-nice.49.mcz

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

Name: Files-nice.49
Author: nice
Time: 7 December 2009, 8:58:18 am
UUID: fd8be897-014b-6d49-b755-169935ee0cc0
Ancestors: Files-nice.48

Fast version of upToAnyOf:do:

=============== Diff against Files-nice.48 ===============

Item was added:
+ ----- Method: StandardFileStream>>upToAnyOf:do: (in category 'read, write, position') -----
+ upToAnyOf: delimiters do: aBlock
+ "Fast version to speed up nextChunk"
+ | pos buffer count result |
+ collection ifNotNil: [
+ (position < readLimit and: [
+ (count := collection indexOfAnyOf: delimiters startingAt: position + 1) <= readLimit and: [
+ count > 0 ] ]) ifTrue: [
+ result := collection copyFrom: position + 1 to: (position := position + count).
+ aBlock value: (collection at: count).
+ ^result ] ].
+ pos := self position.
+ buffer := self next: 2000.
+ (count := buffer indexOfAnyOf: delimiters) > 0 ifTrue:
+ ["Found one of the delimiters part way into buffer"
+ self position: pos + count.
+ aBlock value: (buffer at: count).
+ ^ buffer copyFrom: 1 to: count - 1].
+ self atEnd ifTrue:
+ ["Never found it, and hit end of file"
+ ^ buffer].
+ "Never found it, but there's more..."
+ ^ buffer , (self upToAnyOf: delimiters do: aBlock)!

Item was added:
+ ----- Method: CrLfFileStream>>upToAnyOf:do: (in category 'access') -----
+ upToAnyOf: delimiters do: aBlock
+
+ ^String new: 1000 streamContents: [ :stream |
+ | ch |
+ [ (ch := self next) == nil or: [ (delimiters includes: ch) and: [aBlock value: ch. true] ] ]
+ whileFalse: [ stream nextPut: ch ] ]!