Eliot Miranda uploaded a new version of Collections to project The Trunk: http://source.squeak.org/trunk/Collections-eem.1024.mcz
==================== Summary ====================
Name: Collections-eem.1024 Author: eem Time: 22 November 2022, 7:37:55.158009 pm UUID: 4c57a48d-50a0-4209-a01b-643c0da598f6 Ancestors: Collections-eem.1023
Replace the two implementations of [Byte]String>>substrings with one using the same scheme as SequenceableCollection>>subStrings:; it's at least 23% faster.
=============== Diff against Collections-eem.1023 ===============
Item was removed: - ----- Method: ByteString>>substrings (in category 'converting') ----- - substrings - "Answer an array of the substrings that compose the receiver." - - ^Array streamContents: [ :stream | - | end start | - end := 1. - "find one substring each time through this loop" - [ "find the beginning of the next substring" - (start := self - indexOfAnyOf: CharacterSet nonSeparators - startingAt: end) = 0 ] - whileFalse: [ - "find the end" - end := self - indexOfAnyOf: CharacterSet separators - startingAt: start - ifAbsent: [ self size + 1 ]. - stream nextPut: (self copyFrom: start to: end - 1) ] ]!
Item was changed: ----- Method: String>>substrings (in category 'converting') ----- substrings "Answer an array of the substrings that compose the receiver." + | result size subsequenceStart | + result := OrderedCollection new. + size := self size. + 1 to: size do: + [:i| + (self at: i) isSeparator + ifTrue: + [subsequenceStart ifNotNil: + [result addLast: (self copyFrom: subsequenceStart to: i - 1)]. + subsequenceStart := nil] + ifFalse: + [subsequenceStart ifNil: [subsequenceStart := i]]]. + subsequenceStart ifNotNil: + [result addLast: (self copyFrom: subsequenceStart to: size)]. + ^result asArray + ! - | result end beginning | - result := WriteStream on: (Array new: 10). - end := 0. - "find one substring each time through this loop" - [ "find the beginning of the next substring" - beginning := end+1. - [beginning <= self size and:[(self at: beginning) isSeparator]] - whileTrue:[beginning := beginning + 1]. - beginning <= self size] whileTrue: [ - "find the end" - end := beginning. - [end <= self size and:[(self at: end) isSeparator not]] - whileTrue:[end := end + 1]. - end := end - 1. - result nextPut: (self copyFrom: beginning to: end). - ]. - ^result contents!
squeak-dev@lists.squeakfoundation.org