<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body smarttemplateinserted="true">
    <div id="smartTemplate4-template">Hi,<br>
    </div>
    <div><br>
    </div>
    <div>I had a custom case-insensitive compare function, and it was
      very slow.</div>
    <div><br>
    </div>
    <div>Then I benchmarked it and noticed, case-insensitiveness is
      rarely needed in practice.  <br>
    </div>
    <div><br>
    </div>
    <div>Then I changed it to something like:<br>
      <p><tt><font size="-1"><br>
                  c1:=str1[counter];<br>
                  c2:=str2[counter];<br>
                  if c1 <> c2 then begin<br>
          </font></tt><tt><font size="-1"><tt><font size="-1">         
                c1:=simplewideupcase(c1);<br>
                          c2:=simplewideupcase(c2);<br>
              </font></tt>      end;<br>
          </font></tt></p>
      and it was like 10 times faster<br>
      <br>
      Best,<br>
      Benito </div>
    <div class="moz-cite-prefix">On 31.05.20 14:18, Alexey Tor. via
      fpc-pascal wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:f6a4863b-116f-b04c-0a34-9f426bcd4e86@ya.ru">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <p><tt><font size="-1">function strlicomp(str1,str2 : pwidechar;l
            : SizeInt) : SizeInt;<br>
              var<br>
               counter: sizeint;<br>
               c1, c2: char;<br>
              begin<br>
                counter := 0;<br>
                if l=0 then<br>
                  begin<br>
                    strlicomp := 0;<br>
                    exit;<br>
                  end;<br>
                repeat<br>
                  c1:=simplewideupcase(str1[counter]);<br>
                  c2:=simplewideupcase(str2[counter]);<br>
                  if (c1=#0) or (c2=#0) then break;<br>
                  inc(counter);<br>
                until (c1<>c2) or (counter>=l);<br>
                strlicomp:=ord(c1)-ord(c2);<br>
              end;<br>
            <br>
          </font></tt>suggestions:<br>
        <br>
        a)<br>
              if (c1=#0) or (c2=#0) then break;<br>
        -><br>
         if c1=#0 then break;<br>
         if c2=#0 then break;<br>
         <br>
        b)<br>
        embed upcase to avoid CALL<br>
              c1:=simplewideupcase(str1[counter]);<br>
              c2:=simplewideupcase(str2[counter]);<br>
        -><br>
         c1:= str1[counter];<br>
         c2:= str2[counter];<br>
         if (c1>='a') and (c1<='z') then dec(c1, 32);<br>
         if (c2>='a') and (c2<='z') then dec(c2, 32);<br>
        <br>
        c) not sure..<br>
        we have 2 same diff's <br>
        c1<>c2<br>
        and<br>
        ord(c1)-ord(c2)<br>
        <br>
      </p>
      <pre class="moz-signature" cols="72">Alexey Torgashin</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
fpc-pascal maillist  -  <a class="moz-txt-link-abbreviated" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a>
</pre>
    </blockquote>
  </body>
</html>