<body><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
I moved <span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Collections-ct.875 to treated.</span><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Best,</span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Marcel</span></div><div class="mb_sig"></div><blockquote class="history_container" type="cite" style="border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;">
<p style="color: #AAAAAA; margin-top: 10px;">Am 17.02.2020 20:57:58 schrieb commits@source.squeak.org <commits@source.squeak.org>:</p><div style="font-family:Arial,Helvetica,sans-serif">Christoph Thiede uploaded a new version of Collections to project The Inbox:<br>http://source.squeak.org/inbox/Collections-ct.877.mcz<br><br>==================== Summary ====================<br><br>Name: Collections-ct.877<br>Author: ct<br>Time: 17 February 2020, 8:57:49.278239 pm<br>UUID: bf652ba0-43cc-734d-ac03-7a226cc80463<br>Ancestors: Collections-ul.875<br><br>Extends and realigns version of #findFirst: and #findLast:.<br><br>Second, optimized version after many helpful comments by Levente (ul). Thank you!<br>Replaces Collections-ct.875.<br><br>---<br><br>Performance analysis:<br><br> #findFirst: - '238 per second. 4.2 milliseconds per run. 0.73956 % GC time.'<br> #findFirst:startingAt: - '1,510 per second. 660 microseconds per run. 1.56 % GC time.'<br> #findFirst:startingAt:ifNone: - '1,210 per second. 828 microseconds per run. 2.06 % GC time.'<br> #findFirst:ifNone: - '214 per second. 4.68 milliseconds per run. 0.65987 % GC time.'<br> #findLast: - '210 per second. 4.76 milliseconds per run. 0.66 % GC time.'<br> #findLast:startingAt: - '1,380 per second. 724 microseconds per run. 1.72 % GC time.'<br> #findLast:startingAt:ifNone: - '1,130 per second. 887 microseconds per run. 2 % GC time.'<br> #findLast:ifNone: - '206 per second. 4.86 milliseconds per run. 0.81967 % GC time.'<br><br>Comparing to previous version:<br><br> #findFirst: - '193 per second. 5.19 milliseconds per run. 0.5994 % GC time.' (NOW 23.3% faster)<br> #findLast: - '213 per second. 4.69 milliseconds per run. 0.71986 % GC time.' (NOW 1.4% slower)<br> #findLast:startingAt: - '1,360 per second. 736 microseconds per run. 1.72 % GC time.' (NOW 1.4% faster)<br><br>Measurements code:<br><br> random := Random new.<br> range := 1 to: 256.<br> array := (1 to: 128) collect: [:i | range atRandom: random].<br> values := (1 to: 4096) collect: [:i | range atRandom: random].<br> <br> ({<br> #findFirst: -> [<br> values do: [:x |<br> array findFirst: [:y | x = y]]].<br> #findFirst:startingAt: -> [<br> values pairsDo: [:x :s |<br> array findFirst: [:y | x = y] startingAt: s]].<br> #findFirst:ifNone: -> [<br> values do: [:x |<br> array findFirst: [:y | x = y] ifNone: [123456789 sqrt]]].<br> #findFirst:startingAt:ifNone: -> [<br> values pairsDo: [:x :s |<br> array findFirst: [:y | x = y] startingAt: s ifNone: [123456789 sqrt]]].<br> #findLast: -> [<br> values do: [:x |<br> array findLast: [:y | x = y]]].<br> #findLast:startingAt: -> [<br> values pairsDo: [:x :s |<br> array findLast: [:y | x = y] startingAt: s]].<br> #findLast:ifNone: -> [<br> values do: [:x |<br> array findLast: [:y | x = y] ifNone: [123456789 sqrt]]].<br> #findLast:startingAt:ifNone: -> [<br> values pairsDo: [:x :s |<br> array findLast: [:y | x = y] startingAt: s ifNone: [123456789 sqrt]]].<br> }<br> select: [:assoc | array respondsTo: assoc key])<br> collect: [:assoc | assoc key -> assoc value bench] as: Dictionary<br><br>=============== Diff against Collections-ul.875 ===============<br><br>Item was changed:<br> ----- Method: SequenceableCollection>>findFirst: (in category 'enumerating') -----<br> findFirst: aBlock<br> "Return the index of my first element for which aBlock evaluates as true."<br> <br>+ ^ self findFirst: aBlock startingAt: 1!<br>- | index |<br>- index := 0.<br>- [(index := index + 1) <= self="" size]=""></=><br>- [(aBlock value: (self at: index)) ifTrue: [^index]].<br>- ^ 0!<br><br>Item was added:<br>+ ----- Method: SequenceableCollection>>findFirst:ifNone: (in category 'enumerating') -----<br>+ findFirst: aBlock ifNone: anotherBlock<br>+ "Return the index of my first element for which aBlock evaluates as true. If no element is found, return the value of anotherBlock."<br>+ <br>+ | index |<br>+ (index := self findFirst: aBlock) = 0<br>+ ifTrue: [^ anotherBlock value].<br>+ ^ index!<br><br>Item was added:<br>+ ----- Method: SequenceableCollection>>findFirst:startingAt: (in category 'enumerating') -----<br>+ findFirst: aBlock startingAt: minIndex<br>+ "Return the index of my first element with index >= minIndex for which aBlock evaluates as true."<br>+ <br>+ minIndex to: self size do: [:index |<br>+ (aBlock value: (self at: index)) ifTrue: [^index]].<br>+ ^ 0!<br><br>Item was added:<br>+ ----- Method: SequenceableCollection>>findFirst:startingAt:ifNone: (in category 'enumerating') -----<br>+ findFirst: aBlock startingAt: minIndex ifNone: anotherBlock<br>+ "Return the index of my first element with index >= minIndex for which aBlock evaluates as true. If no element is found, return the value of anotherBlock."<br>+ <br>+ | index |<br>+ (index := self findFirst: aBlock startingAt: minIndex) = 0<br>+ ifTrue: [^ anotherBlock value].<br>+ ^ index!<br><br>Item was changed:<br> ----- Method: SequenceableCollection>>findLast: (in category 'enumerating') -----<br> findLast: aBlock<br> "Return the index of my last element for which aBlock evaluates as true."<br> <br>+ ^ self findLast: aBlock startingAt: 1!<br>- | index |<br>- index := self size + 1.<br>- [(index := index - 1) >= 1] whileTrue:<br>- [(aBlock value: (self at: index)) ifTrue: [^index]].<br>- ^ 0!<br><br>Item was added:<br>+ ----- Method: SequenceableCollection>>findLast:ifNone: (in category 'enumerating') -----<br>+ findLast: aBlock ifNone: anotherBlock<br>+ "Return the index of my last element for which aBlock evaluates as true. If no element is found, return the value of anotherBlock."<br>+ <br>+ | index |<br>+ (index := self findLast: aBlock) = 0<br>+ ifTrue: [^ anotherBlock value].<br>+ ^ index!<br><br>Item was changed:<br> ----- Method: SequenceableCollection>>findLast:startingAt: (in category 'enumerating') -----<br>+ findLast: aBlock startingAt: minIndex<br>+ "Return the index of my last element with index >= minIndex for which aBlock evaluates as true."<br>- findLast: aBlock startingAt: i<br>- "Return the index of my last element with index >= i for which aBlock evaluates as true."<br> <br>+ self size to: minIndex by: -1 do: [:index |<br>+ (aBlock value: (self at: index)) ifTrue: [^index]].<br>- | index |<br>- index := self size + 1.<br>- [(index := index - 1) >= i] whileTrue:<br>- [(aBlock value: (self at: index)) ifTrue: [^index]].<br> ^ 0!<br><br>Item was added:<br>+ ----- Method: SequenceableCollection>>findLast:startingAt:ifNone: (in category 'enumerating') -----<br>+ findLast: aBlock startingAt: minIndex ifNone: anotherBlock<br>+ "Return the index of my last element with index >= minIndex for which aBlock evaluates as true. If no element is found, return the value of anotherBlock."<br>+ <br>+ | index |<br>+ (index := self findLast: aBlock startingAt: minIndex) = 0<br>+ ifTrue: [^ anotherBlock value].<br>+ ^ index!<br><br><br></div></blockquote>
</div></body>