2007-06-06 Stephen Compall * kernel/ArrayColl.st: Use #do: instead of #inject:into: in #join:. * kernel/SeqCollect.st: Remove #flatten: and rename/rewrite #flatten to #joinAll. --- orig/kernel/ArrayColl.st +++ mod/kernel/ArrayColl.st @@ -122,13 +122,13 @@ join: aCollection "Where aCollection is a collection of SequenceableCollections, answer a new instance with all the elements therein, in order." - | newInst | + | newInst start | newInst := self new: (aCollection inject: 0 into: [:size :each | size + each size]). - aCollection inject: 1 into: [:start :subColl | | nextStart | - newInst replaceFrom: start to: (nextStart := start + subColl size) - 1 - with: subColl. - nextStart]. + start := 1. + aCollection do: [:subColl | + newInst replaceFrom: start to: (start := start + subColl size) - 1 + with: subColl]. ^newInst ! ! --- orig/kernel/SeqCollect.st +++ mod/kernel/SeqCollect.st @@ -545,14 +545,7 @@ !SequenceableCollection methodsFor: 'concatenating'! -flatten: aSpecies - "Answer a new collection of aSpecies, which should respond to - #join:, with all the elements of all my elements, which should be - collections, in order." - ^aSpecies join: self -! - -flatten +joinAll "Answer a new collection like my first element, with all the elements (in order) of all my elements, which should be collections. @@ -563,7 +556,7 @@ #('hello, ' 'world') flatten => 'hello, world'" ^self isEmpty ifTrue: [#()] - ifFalse: [self flatten: self first species] + ifFalse: [self first species join: self] ! !