<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:darin&#64;apple.com" title="Darin Adler &lt;darin&#64;apple.com&gt;"> <span class="fn">Darin Adler</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [INTL] Implement Intl.NumberFormat.prototype.resolvedOptions ()"
   href="https://bugs.webkit.org/show_bug.cgi?id=147602">bug 147602</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Attachment #267982 Flags</td>
           <td>review?
           </td>
           <td>review+
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [INTL] Implement Intl.NumberFormat.prototype.resolvedOptions ()"
   href="https://bugs.webkit.org/show_bug.cgi?id=147602#c24">Comment # 24</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [INTL] Implement Intl.NumberFormat.prototype.resolvedOptions ()"
   href="https://bugs.webkit.org/show_bug.cgi?id=147602">bug 147602</a>
              from <span class="vcard"><a class="email" href="mailto:darin&#64;apple.com" title="Darin Adler &lt;darin&#64;apple.com&gt;"> <span class="fn">Darin Adler</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=267982&amp;action=diff" name="attach_267982" title="Patch">attachment 267982</a> <a href="attachment.cgi?id=267982&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=267982&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=267982&amp;action=review</a>

Seems like a reasonable first cut. We need to remember to do some performance testing and tuning on this; there’s a lot of memory allocation here.

<span class="quote">&gt; Source/JavaScriptCore/runtime/IntlNumberFormat.cpp:94
&gt; +static bool isWellFormedCurrencyCode(const String&amp; currency)</span >

Might be worth marking some of these super-simple functions inline, especially if they have only one or two call sites.

<span class="quote">&gt; Source/JavaScriptCore/runtime/IntlNumberFormat.cpp:100
&gt; +static unsigned computeCurrencySortKey(const char* currency)</span >

Ditto.

<span class="quote">&gt; Source/JavaScriptCore/runtime/IntlNumberFormat.cpp:106
&gt; +static unsigned extractCurrencySortKey(std::pair&lt;const char*, unsigned&gt;* currencyMinorUnit)</span >

Ditto.

<span class="quote">&gt; Source/JavaScriptCore/runtime/IntlNumberFormat.cpp:143
&gt; +    std::array&lt;std::pair&lt;const char*, unsigned&gt;, 26&gt; currencyMinorUnits = { {
&gt; +        { &quot;BHD&quot;, 3 },
&gt; +        { &quot;BIF&quot;, 0 },
&gt; +        { &quot;BYR&quot;, 0 },
&gt; +        { &quot;CLF&quot;, 4 },
&gt; +        { &quot;CLP&quot;, 0 },
&gt; +        { &quot;DJF&quot;, 0 },
&gt; +        { &quot;GNF&quot;, 0 },
&gt; +        { &quot;IQD&quot;, 3 },
&gt; +        { &quot;ISK&quot;, 0 },
&gt; +        { &quot;JOD&quot;, 3 },
&gt; +        { &quot;JPY&quot;, 0 },
&gt; +        { &quot;KMF&quot;, 0 },
&gt; +        { &quot;KRW&quot;, 0 },
&gt; +        { &quot;KWD&quot;, 3 },
&gt; +        { &quot;LYD&quot;, 3 },
&gt; +        { &quot;OMR&quot;, 3 },
&gt; +        { &quot;PYG&quot;, 0 },
&gt; +        { &quot;RWF&quot;, 0 },
&gt; +        { &quot;TND&quot;, 3 },
&gt; +        { &quot;UGX&quot;, 0 },
&gt; +        { &quot;UYI&quot;, 0 },
&gt; +        { &quot;VND&quot;, 0 },
&gt; +        { &quot;VUV&quot;, 0 },
&gt; +        { &quot;XAF&quot;, 0 },
&gt; +        { &quot;XOF&quot;, 0 },
&gt; +        { &quot;XPF&quot;, 0 }
&gt; +    } };</span >

I believe this will do some work every time the function is called. We need to make sure this actually gets compiled in a way that doesn’t do the array initialization each time, for efficiently. Might need to eschew the use of std::array, or mark this as const, to achieve that.

<span class="quote">&gt; Source/JavaScriptCore/runtime/IntlNumberFormat.cpp:144
&gt; +    std::pair&lt;const char*, unsigned&gt;* currencyMinorUnit = tryBinarySearch&lt;std::pair&lt;const char*, unsigned&gt;&gt;(currencyMinorUnits, currencyMinorUnits.size(), computeCurrencySortKey(currency.utf8().data()), extractCurrencySortKey);</span >

Would read better with the use of auto*. Unclear on why we need to explicitly pass the type in when invoking the tryBinarySearch function template; I’d expect it to work without specifying that explicitly.

Should overload computeCurrencySortKey to work on a const String&amp; or StringView correctly; doing memory allocation just to convert the String to a CString, just to get the first three characters of the string, is not great.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>