<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p>Thanks for your thoughts!</p>
<p><br>
</p>
<p>> <span style="font-size:12pt">The new variant also changes the semantics, because it accepts unicode </span></p>
<div>> digits. For example, the following won't raise an error but yield 9:</div>
<div>> </div>
<div>>          '{', (Character value: 16r1d7eb) asString, '}' format: (1 to: 10).</div>
<div><br>
</div>
<div>Interesting, but do you really think this is an undesired behavior?</div>
<div>I changed the method with the aim to increase the readability, which was also impaired by the hardcoded numbers.</div>
<div>In my eyes it is a nice side effect to support other kinds of Unicode values - NumberParser does the same.</div>
<div><br>
</div>
<div>Christoph</div>
<p></p>
<div id="x_Signature">
<div name="x_divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Levente Uzonyi <leves@caesar.elte.hu><br>
<b>Gesendet:</b> Freitag, 16. August 2019 00:51:14<br>
<b>An:</b> squeak-dev@lists.squeakfoundation.org<br>
<b>Betreff:</b> Re: [squeak-dev] The Inbox: Collections-ct.851.mcz</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">On Thu, 15 Aug 2019, commits@source.squeak.org wrote:<br>
<br>
> A new version of Collections was added to project The Inbox:<br>
> <a href="http://source.squeak.org/inbox/Collections-ct.851.mcz">http://source.squeak.org/inbox/Collections-ct.851.mcz</a><br>
><br>
> ==================== Summary ====================<br>
><br>
> Name: Collections-ct.851<br>
> Author: ct<br>
> Time: 15 August 2019, 11:36:23.694735 pm<br>
> UUID: 6c7113c6-9d09-bf4c-9b32-e2001870bb56<br>
> Ancestors: Collections-ct.850<br>
><br>
> Refactor String>>#format: according to Text>>#format:<br>
><br>
> I could not find any significant performance impacts.<br>
<br>
Difference only appears when there are substitutions to be done. The more <br>
substitutions you have, the higher the difference in performance will be.<br>
This new version takes up to ~40% longer than the current implementation, <br>
which is still not optimal btw.<br>
The new variant also changes the semantics, because it accepts unicode <br>
digits. For example, the following won't raise an error but yield 9:<br>
<br>
         '{', (Character value: 16r1d7eb) asString, '}' format: (1 to: 10).<br>
<br>
Levente<br>
<br>
><br>
> We have some duplication between both #format: implementations. Do you thing this is a problem at the current scale?<br>
><br>
> =============== Diff against Collections-ct.850 ===============<br>
><br>
> Item was changed:<br>
>  ----- Method: String>>format: (in category 'formatting') -----<br>
> + format: arguments <br>
> +      "format the receiver with arguments <br>
> - format: aCollection <br>
> -      "format the receiver with aCollection<br>
><br>
>        simplest example:<br>
>        'foo {1} bar' format: {Date today}.<br>
><br>
>        complete example:<br>
>        '\{ \} \\ foo {1} bar {2}' format: {12. 'string'}.<br>
>        "<br>
> +      ^self class new: self size * 11 // 10 streamContents: [ :output |<br>
> -      ^self class new: self size * 11 // 10 "+10%" streamContents: [ :output |<br>
>                | lastIndex nextIndex |<br>
>                lastIndex := 1.<br>
>                [ (nextIndex := self indexOfAnyOf: FormatCharacterSet startingAt: lastIndex) = 0 ] whileFalse: [<br>
>                        nextIndex = lastIndex ifFalse: [<br>
>                                output next: nextIndex - lastIndex putAll: self startingAt: lastIndex ].<br>
> +                      (self at: nextIndex) caseOf: {<br>
> +                              [$\] -> [ output nextPut: (self at: (nextIndex := nextIndex + 1)) ].<br>
> +                              [${] -> [<br>
> -                      (self at: nextIndex) == $\<br>
> -                              ifTrue: [ output nextPut: (self at: (nextIndex := nextIndex + 1)) ]<br>
> -                              ifFalse: [ "${"<br>
>                                        "Parse the index - a positive integer in base 10."<br>
> +                                      | character collectionIndex |<br>
> -                                      | digitValue collectionIndex |<br>
>                                        collectionIndex := 0.<br>
> +                                      [ (character := self at: (nextIndex := nextIndex + 1)) isDigit ] whileTrue: [<br>
> +                                              collectionIndex := collectionIndex * 10 + character digitValue ].<br>
> +                                      character = $} ifFalse: [ self error: '$} expected' ].<br>
> +                                      output nextPutAll: (arguments at: collectionIndex) asString ] }.<br>
> -                                      [ (digitValue := self basicAt: (nextIndex := nextIndex + 1)) between: 48 "$0 asciiValue" and: 57 "$9 asciiValue" ] whileTrue: [<br>
> -                                              collectionIndex := collectionIndex * 10 + digitValue - 48. "$0 asciiValue" ].<br>
> -                                      digitValue =  125 "$} asciiValue" ifFalse: [ self error: '$} expected' ].<br>
> -                                      output nextPutAll: (aCollection at: collectionIndex) asString ].<br>
>                        lastIndex := nextIndex + 1 ].<br>
>                lastIndex <= self size ifTrue: [<br>
>                        output next: self size - lastIndex + 1 putAll: self startingAt: lastIndex ] ]!<br>
<br>
</div>
</span></font>
</body>
</html>