The Trunk: Collections-tonyg.734.mcz

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

The Trunk: Collections-tonyg.734.mcz

Patrick Rein uploaded a new version of Collections to project The Trunk:

==================== 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
+ !