summaryrefslogtreecommitdiff
path: root/src/backend/tsearch/ts_locale.c
diff options
context:
space:
mode:
authorTom Lane2014-02-23 21:59:05 +0000
committerTom Lane2014-02-23 21:59:05 +0000
commit769065c1b2471f484bb48bb58a8bdcf1d12a419c (patch)
treedc0344a494ceabe955b403b992f4092ec4140f8b /src/backend/tsearch/ts_locale.c
parent49c817eab78c6f0ce8c3bf46766b73d6cf3190b7 (diff)
Prefer pg_any_to_server/pg_server_to_any over pg_do_encoding_conversion.
A large majority of the callers of pg_do_encoding_conversion were specifying the database encoding as either source or target of the conversion, meaning that we can use the less general functions pg_any_to_server/pg_server_to_any instead. The main advantage of using the latter functions is that they can make use of a cached conversion-function lookup in the common case that the other encoding is the current client_encoding. It's notationally cleaner too in most cases, not least because of the historical artifact that the latter functions use "char *" rather than "unsigned char *" in their APIs. Note that pg_any_to_server will apply an encoding verification step in some cases where pg_do_encoding_conversion would have just done nothing. This seems to me to be a good idea at most of these call sites, though it partially negates the performance benefit. Per discussion of bug #9210.
Diffstat (limited to 'src/backend/tsearch/ts_locale.c')
-rw-r--r--src/backend/tsearch/ts_locale.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/backend/tsearch/ts_locale.c b/src/backend/tsearch/ts_locale.c
index d73687af9e0..f9490c835dd 100644
--- a/src/backend/tsearch/ts_locale.c
+++ b/src/backend/tsearch/ts_locale.c
@@ -209,10 +209,7 @@ t_readline(FILE *fp)
(void) pg_verify_mbstr(PG_UTF8, buf, len, false);
/* And convert */
- recoded = (char *) pg_do_encoding_conversion((unsigned char *) buf,
- len,
- PG_UTF8,
- GetDatabaseEncoding());
+ recoded = pg_any_to_server(buf, len, PG_UTF8);
if (recoded == buf)
{
/*