• Benno Schulenberg's avatar
    chars: make searching case-insensitively some ten percent faster · c8bc05b1
    Benno Schulenberg authored
    It is quicker to do a handful of superfluous compares at the end of
    each line than it is to compute and keep track of and compare the
    remaining line length the whole time.
    
    The typical line is some sixty characters long, the typical search
    string ten characters -- with a shorter search string the speedup is
    even higher: some fifteen percent.  Only when the string is longer
    than half the average line length does searching become slower with
    this new method.
    
    All this for a UTF-8 locale.  For a C locale it makes no difference.
    c8bc05b1
chars.c 21.3 KB