Avoid rescanning prefixes when choosing a dollar-quote delimiter appendStringLiteralDQ() and pg_get_functiondef() pick a dollar-quote delimiter by repeatedly extending a candidate until it no longer occurs in the string being quoted, restarting the strstr() search from the beginning each time. Since each candidate extends the previous one, it cannot match before that position, so we can resume the search at the previous match.
It's easy to show a performance benefit with a specially-crafted function body. In functions that occur in the real world, this won't make any difference, but it's a very straightforward optimization so might as well do it. Author: Chao Li <[email protected]> Discussion: https://www.postgresql.org/message-id/[email protected] Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/514bfe2c6dffba2d7a6b7ea7cf029e04a7c41563 Modified Files -------------- src/backend/utils/adt/ruleutils.c | 8 ++++++-- src/fe_utils/string_utils.c | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-)
