[Pkg] The Trunk: Files-ul.89.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Sep 20 04:02:04 UTC 2010


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

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

Name: Files-ul.89
Author: ul
Time: 20 September 2010, 5:52:06.563 am
UUID: faa4d221-40e8-e648-89e9-f4faa1bf8503
Ancestors: Files-bf.88

- enh: keep the fetched data in StandardFileStream>>upTo:
 and StandardFileStream>>upToAnyOf:do: if read buffering is enabled.

=============== Diff against Files-bf.88 ===============

Item was changed:
  ----- Method: StandardFileStream>>upTo: (in category 'read, write, position') -----
  upTo: delimiter
  
  	| pos |
  	collection ifNotNil: [
  		(position < readLimit and: [
  			(pos := collection indexOf: delimiter startingAt: position + 1) <= readLimit and: [
  				pos > 0 ] ]) ifTrue: [
  					^collection copyFrom: position + 1 to: (position := pos) - 1 ] ].
  	^self collectionSpecies streamContents: [ :stream |
  		| buffer bytesRead |
  		buffer := collection 
  			ifNil: [ self collectionSpecies new: 2000 ]
  			ifNotNil: [
  				position < readLimit ifTrue: [
  					stream next: readLimit - position putAll: collection startingAt: position + 1.
  					position := readLimit ].
  				collection ].
  		[
  			bytesRead := self readInto: buffer startingAt: 1 count: buffer size.
  			((pos := buffer indexOf: delimiter startingAt: 1) = 0 or: [ pos > bytesRead ])
  				ifTrue: [ 
  					stream next: bytesRead putAll: buffer startingAt: 1.
  					bytesRead > 0 "Try again if we could read something last time." ]
  				ifFalse: [
  					stream next: pos - 1 putAll: buffer startingAt: 1.
+ 					collection 
+ 						ifNil: [ self skip: pos - bytesRead ]
+ 						ifNotNil: [
+ 							position := pos.
+ 							readLimit := bytesRead ].
- 					self skip: pos - bytesRead.
  					false "Found the delimiter." ] ] whileTrue ]!

Item was changed:
  ----- Method: StandardFileStream>>upToAnyOf:do: (in category 'read, write, position') -----
  upToAnyOf: delimiters do: aBlock
  
  	| pos |
  	collection ifNotNil: [
  		(position < readLimit and: [
  			(pos := collection indexOfAnyOf: delimiters startingAt: position + 1) <= readLimit and: [
  				pos > 0 ] ]) ifTrue: [
  					| result |
  					result := collection copyFrom: position + 1 to: (position := pos) - 1 .
  					aBlock value: (collection at: position).
  					^result ] ].
  	^self collectionSpecies streamContents: [ :stream |
  		| buffer bytesRead |
  		buffer := collection 
  			ifNil: [ self collectionSpecies new: 2000 ]
  			ifNotNil: [
  				position < readLimit ifTrue: [
  					stream next: readLimit - position putAll: collection startingAt: position + 1.
  					position := readLimit ].
  				collection ].
  		[
  			bytesRead := self readInto: buffer startingAt: 1 count: buffer size.
  			((pos := buffer indexOfAnyOf: delimiters startingAt: 1) = 0 or: [ pos > bytesRead ])
  				ifTrue: [ 
  					stream next: bytesRead putAll: buffer startingAt: 1.
  					bytesRead > 0 "Try again if we could read something last time." ]
  				ifFalse: [
  					stream next: pos - 1 putAll: buffer startingAt: 1.
+ 					collection 
+ 						ifNil: [ self skip: pos - bytesRead ]
+ 						ifNotNil: [
+ 							position := pos.
+ 							readLimit := bytesRead ].
- 					self skip: pos - bytesRead.
  					false "Found the delimiter." ] ] whileTrue.
  		bytesRead = 0 ifFalse: [
  			aBlock value: (buffer at: pos) ] ]!



More information about the Packages mailing list