OSDN Git Service

Fix performance issues in replace_text(), replace_text_regexp(), and
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 8 Nov 2006 19:22:25 +0000 (19:22 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 8 Nov 2006 19:22:25 +0000 (19:22 +0000)
commita5cf12e2ef775abf4cfe7dee50d2c065047e19a0
treecfc802a585f5878be03637912f673ce0a59c8a57
parent9d6f26325f2ae29e45d68eaad08a28369625ffca
Fix performance issues in replace_text(), replace_text_regexp(), and
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.
src/backend/utils/adt/varlena.c