[squeak-dev] The Inbox: Collections-tonyg.734.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Feb 23 19:08:14 UTC 2017


A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-tonyg.734.mcz

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

Name: Collections-tonyg.734
Author: tonyg
Time: 23 February 2017, 2:08:07.162997 pm
UUID: 9edf6f29-ea5e-4c3b-9d05-03c54d4ba86c
Ancestors: Collections-topa.733

Factor out #upToPosition:, which lets us address the discrepancy between position counting bytes in MultiByteFileStream, but #next: expecting a count of items in #upToAll:. This is the first half of a fix for Mantis #4665. See also MultilingualTests-tonyg.22.

=============== Diff against Collections-topa.733 ===============

Item was changed:
  ----- Method: PositionableStream>>upToAll: (in category 'accessing') -----
  upToAll: aCollection
  	"Answer a subcollection from the current access position to the occurrence (if any, but not inclusive) of aCollection. If aCollection is not in the stream, answer the entire rest of the stream."
  
  	| startPos endMatch result |
  	startPos := self position.
  	(self match: aCollection) 
  		ifTrue: [endMatch := self position.
  			self position: startPos.
+ 			result := self upToPosition: endMatch - aCollection size.
- 			result := self next: endMatch - startPos - aCollection size.
  			self position: endMatch.
  			^ result]
  		ifFalse: [self position: startPos.
  			^ self upToEnd]!

Item was added:
+ ----- Method: PositionableStream>>upToPosition: (in category 'accessing') -----
+ upToPosition: anInteger
+ 	"Answer a subcollection containing items starting from the current position and ending including the given position. Usefully different to #next: in that in the case of MultiByteFileStream, and perhaps others, positions measure in terms of encoded items, while #next: convention is to name a number of items, independent of their encoding in the underlying buffer."
+ 	^ self next: anInteger - position
+ !



More information about the Squeak-dev mailing list