summaryrefslogtreecommitdiff
path: root/src/backend/libpq
diff options
context:
space:
mode:
authorAndres Freund2018-07-22 21:58:01 +0000
committerAndres Freund2018-07-22 21:58:23 +0000
commit86eaf208ea048936df6be77276a246d3f92e9620 (patch)
treed0b7d529bba5f072457c003c951d05ca2aa90caa /src/backend/libpq
parent3522d0eaba5a976f09a48810dd25dff6ab3565df (diff)
Hand code string to integer conversion for performance.
As benchmarks show, using libc's string-to-integer conversion is pretty slow. At least part of the reason for that is that strtol[l] have to be more generic than what largely is required inside pg. This patch considerably speeds up int2/int4 input (int8 already was already using hand-rolled code). Most of the existing pg_atoi callers have been converted. But as one requires pg_atoi's custom delimiter functionality, and as it seems likely that there's external pg_atoi users, it seems sensible to just keep pg_atoi around. Author: Andres Freund Reviewed-By: Robert Haas Discussion: https://postgr.es/m/20171208214437.qgn6zdltyq5hmjpk@alap3.anarazel.de
Diffstat (limited to 'src/backend/libpq')
-rw-r--r--src/backend/libpq/pqmq.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/libpq/pqmq.c b/src/backend/libpq/pqmq.c
index 201075dd477..4fbc6b5115d 100644
--- a/src/backend/libpq/pqmq.c
+++ b/src/backend/libpq/pqmq.c
@@ -286,10 +286,10 @@ pq_parse_errornotice(StringInfo msg, ErrorData *edata)
edata->hint = pstrdup(value);
break;
case PG_DIAG_STATEMENT_POSITION:
- edata->cursorpos = pg_atoi(value, sizeof(int), '\0');
+ edata->cursorpos = pg_strtoint32(value);
break;
case PG_DIAG_INTERNAL_POSITION:
- edata->internalpos = pg_atoi(value, sizeof(int), '\0');
+ edata->internalpos = pg_strtoint32(value);
break;
case PG_DIAG_INTERNAL_QUERY:
edata->internalquery = pstrdup(value);
@@ -316,7 +316,7 @@ pq_parse_errornotice(StringInfo msg, ErrorData *edata)
edata->filename = pstrdup(value);
break;
case PG_DIAG_SOURCE_LINE:
- edata->lineno = pg_atoi(value, sizeof(int), '\0');
+ edata->lineno = pg_strtoint32(value);
break;
case PG_DIAG_SOURCE_FUNCTION:
edata->funcname = pstrdup(value);