summaryrefslogtreecommitdiff
path: root/xmlhelp/source/cxxhelp/inc
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2015-07-04 21:02:35 -0500
committerStephan Bergmann <sbergman@redhat.com>2015-07-07 06:59:59 +0000
commitbb9d628552d7a91680ef04c08b1f49cee4ada6bf (patch)
treed7d3b201c86e5ffccd83734000ad61543c025f6e /xmlhelp/source/cxxhelp/inc
parent9d7727737b067c5228f129737046f718d5965659 (diff)
performance tuning of rtl_ustr_indexOfAscii_WithLength()
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/16763 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'xmlhelp/source/cxxhelp/inc')
0 files changed, 0 insertions, 0 deletions