• Norbert Thiebaud's avatar
    performance tuning of rtl_ustr_indexOfAscii_WithLength() · bb9d6285
    Norbert Thiebaud yazdı
    lcov over make check showed
    
     98      4699997 : sal_Int32 rtl_ustr_indexOfAscii_WithLength(
     99              :     sal_Unicode const * str, sal_Int32 len,
     100             :     char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
     101             : {
     102     4699997 :     assert(len >= 0);
     103     4699997 :     assert(subLen >= 0);
     104     4699997 :     if (subLen > 0 && subLen <= len) {
     105             :         sal_Int32 i;
     106    54014537 :         for (i = 0; i <= len - subLen; ++i) {
     107    51036513 :             if (rtl_ustr_asciil_reverseEquals_WithLength(
     108    51036523 :                     str + i, subStr, subLen))
     109             :             {
     110      205482 :                 return i;
     111             :             }
     112             :         }
     113             :     }
     114     4494505 :     return -1;
     115             : }
    
    so
    1/ in 95% of the cases the result is not-found.. _that_ is the hot path
    2/ we are calling rtl_ustr_asciil_reverseEquals_WithLength close to 11 times
       per call.. (average ~ len - subLen, due to the high miss ratio)
    
    so let's first search for the first byte of the substring
    to optimize the 'miss' case, which is the most common one.
    
    Change-Id: I20ef0821db2ff0db5935dd562844a947a14aff64
    Reviewed-on: https://gerrit.libreoffice.org/16763Tested-by: 's avatarJenkins <ci@libreoffice.org>
    Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
    bb9d6285
Adı
Son kayıt (commit)
Son güncelleme
..
alloc_arena.cxx Loading commit data...
alloc_arena.hxx Loading commit data...
alloc_cache.cxx Loading commit data...
alloc_cache.hxx Loading commit data...
alloc_fini.cxx Loading commit data...
alloc_global.cxx Loading commit data...
alloc_impl.hxx Loading commit data...
bootstrap.cxx Loading commit data...
byteseq.cxx Loading commit data...
cipher.cxx Loading commit data...
cmdargs.cxx Loading commit data...
crc.cxx Loading commit data...
digest.cxx Loading commit data...
hash.cxx Loading commit data...
hash.hxx Loading commit data...
locale.cxx Loading commit data...
math.cxx Loading commit data...
random.cxx Loading commit data...
rtl_process.cxx Loading commit data...
strbuf.cxx Loading commit data...
strimp.cxx Loading commit data...
strimp.hxx Loading commit data...
string.cxx Loading commit data...
strtmpl.cxx Loading commit data...
unload.cxx Loading commit data...
uri.cxx Loading commit data...
ustrbuf.cxx Loading commit data...
ustring.cxx Loading commit data...
uuid.cxx Loading commit data...