The Trunk: Collections-ul.782.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-ul.782.mcz

commits-2
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.782.mcz

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

Name: Collections-ul.782
Author: ul
Time: 5 February 2018, 9:00:26.138464 pm
UUID: e2bb4a8b-6a0e-4342-b347-4f2226460a85
Ancestors: Collections-mt.781

- various minor tweaks

=============== Diff against Collections-mt.781 ===============

Item was changed:
  ----- Method: Ascii85Converter>>padOfSize: (in category 'private') -----
+ padOfSize: anInteger
- padOfSize: aNumber
 
+ anInteger = 1 ifTrue: [ ^#[0] ].
+ anInteger = 2 ifTrue: [ ^#[0 0] ].
+ anInteger = 3 ifTrue: [ ^#[0 0 0] ].
+ self error: 'Should not reach'!
- aNumber = 1 ifTrue: [^ #(0)].
- aNumber = 2 ifTrue: [^ #(0 0)].
- aNumber = 3 ifTrue: [^ #(0 0 0)].
- self error: 'Should not reach'.!

Item was changed:
  ----- Method: ByteString>>asIntegerSigned: (in category 'converting') -----
  asIntegerSigned: signed
  "Return the first decimal integer I can find or nil."
 
  | index integerValue result size negative |
  (size := self size) <= 16 ifFalse: [ ^super asIntegerSigned: signed ].
  "Find the first character between $0 and $9."
  index := 0.
+ [
+ (index := index + 1) <= size ifFalse: [ ^nil "There are no digits in this string." ].
+ (integerValue := self basicAt: index) <= 47 "$0 asInteger - 1"
+ or: [ 58 "$9 asInteger + 1" <= integerValue ] ] whileTrue.
+ "Check the sign."
- [ (index := index + 1) <= size and: [
- (integerValue := (self at: index) asInteger) <= 47 "$0 asInteger - 1" or: [
- 58 "$9 asInteger + 1" <= integerValue ] ] ] whileTrue.
- index <= size ifFalse: [ ^nil ].
  negative := signed and: [ 2 <= index and: [ (self at: index - 1) == $- ] ].
  "Parse the number."
  result := integerValue - 48 "$0 asInteger".
  [ (index := index + 1) <= size
+ and: [ (integerValue := self basicAt: index) <= 57 "$9 asInteger"
- and: [ (integerValue := (self at: index) asInteger) <= 57 "$9 asInteger"
  and: [ 48 "$0 asInteger" <= integerValue ] ] ]  whileTrue: [
  result := result * 10 + integerValue - 48 ].
  negative ifTrue: [ ^result negated ].
  ^result!

Item was changed:
  ----- Method: SequenceableCollection>>copyReplaceFrom:to:with: (in category 'copying') -----
  copyReplaceFrom: start to: stop with: replacementCollection
  "Answer a copy of the receiver satisfying the following conditions: If
  stop is less than start, then this is an insertion; stop should be exactly
  start-1, start = 1 means insert before the first character, start = size+1
  means append after last character. Otherwise, this is a replacement; start
  and stop have to be within the receiver's bounds."
 
  | newSequenceableCollection newSize endReplacement |
- newSize := self size - (stop - start + 1) + replacementCollection size.
  endReplacement := start - 1 + replacementCollection size.
+ newSize := self size + endReplacement - stop.
  newSequenceableCollection := self species new: newSize.
  start > 1 ifTrue:[
  newSequenceableCollection
  replaceFrom: 1
  to: start - 1
  with: self
  startingAt: 1].
  start <= endReplacement ifTrue:[
  newSequenceableCollection
  replaceFrom: start
  to: endReplacement
  with: replacementCollection
  startingAt: 1].
  endReplacement < newSize ifTrue:[
  newSequenceableCollection
  replaceFrom: endReplacement + 1
  to: newSize
  with: self
  startingAt: stop + 1].
  ^newSequenceableCollection!

Item was changed:
  ----- Method: String>>endsWith: (in category 'testing') -----
  endsWith: sequence
  "Answer true if the receiver ends with the argument collection. The comparison is case-sensitive."
 
  | index sequenceSize offset |
+ sequence isString ifFalse: [ ^super endsWith: sequence ].
+ (sequenceSize := sequence size) = 0 ifTrue: [ ^false ]. "old convention"
+ (offset := self size - sequenceSize) < 0 ifTrue: [ ^false ].
- sequence isString ifFalse: [ ^ super endsWith: sequence ].
- ((sequenceSize := sequence size) = 0 or: [ (offset := self size - sequenceSize) < 0 ]) ifTrue: [ ^false ].
  index := 0.
  [ (index := index + 1) <= sequenceSize ] whileTrue: [
  (sequence at: index) == (self at: index + offset) ifFalse: [ ^false ] ].
  ^true!