• Tom Lane's avatar
    Fix performance issues in replace_text(), replace_text_regexp(), and · a5cf12e2
    Tom Lane authored
    text_to_array(): they all had O(N^2) behavior on long input strings in
    multibyte encodings, because of repeated rescanning of the input text to
    identify substrings whose positions/lengths were computed in characters
    instead of bytes.  Fix by tracking the current source position as a char
    pointer as well as a character-count.  Also avoid some unnecessary palloc
    operations.  text_to_array() also leaked memory intracall due to failure
    to pfree temporary strings.  Per gripe from Tatsuo Ishii.
    a5cf12e2
varlena.c 63.9 KB