mirror of
https://github.com/postgres/postgres.git
synced 2026-01-13 12:22:55 +03:00
Let regexp_replace() make use of REG_NOSUB when feasible.
If the replacement string doesn't contain \1...\9, then we don't need sub-match locations, so we can use the REG_NOSUB optimization here too. There's already a pre-scan of the replacement string to look for backslashes, so extend that to check for digits, and refactor to allow that to happen before we compile the regexp. While at it, try to speed up the pre-scan by using memchr() instead of a handwritten loop. It's likely that this is lost in the noise compared to the regexp processing proper, but maybe not. In any case, this coding is shorter. Also, add some test cases to improve the poor coverage of appendStringInfoRegexpSubstr(). Discussion: https://postgr.es/m/3534632.1628536485@sss.pgh.pa.us
This commit is contained in:
@@ -33,8 +33,9 @@ extern bool SplitDirectoriesString(char *rawstring, char separator,
|
||||
List **namelist);
|
||||
extern bool SplitGUCList(char *rawstring, char separator,
|
||||
List **namelist);
|
||||
extern text *replace_text_regexp(text *src_text, void *regexp,
|
||||
extern text *replace_text_regexp(text *src_text, text *pattern_text,
|
||||
text *replace_text,
|
||||
int cflags, Oid collation,
|
||||
int search_start, int n);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user