Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed14f88

Browse files
author
Thomas G. Lockhart
committed
Change logic slightly to avoid one unnecessary calculation. No big deal.
1 parent c06331a commit ed14f88

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/backend/utils/adt/varchar.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.13 1997/12/16 15:59:09 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.14 1997/12/23 19:24:43 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -49,12 +49,12 @@
4949
* len is the length specified in () plus VARHDRSZ bytes. (XXX dummy is here
5050
* because we pass typelem as the second argument for array_in.)
5151
*/
52-
char *
52+
char *
5353
bpcharin(char *s, int dummy, int typlen)
5454
{
5555
char *result,
5656
*r;
57-
int len = typlen - VARHDRSZ;
57+
int len;
5858
int i;
5959

6060
if (s == NULL)
@@ -69,6 +69,10 @@ bpcharin(char *s, int dummy, int typlen)
6969
len = strlen(s);
7070
typlen = len + VARHDRSZ;
7171
}
72+
else
73+
{
74+
len = typlen - VARHDRSZ;
75+
}
7276

7377
if (len > 4096)
7478
elog(WARN, "bpcharin: length of char() must be less than 4096");
@@ -90,7 +94,7 @@ bpcharin(char *s, int dummy, int typlen)
9094
return (result);
9195
}
9296

93-
char *
97+
char *
9498
bpcharout(char *s)
9599
{
96100
char *result;
@@ -150,7 +154,7 @@ varcharin(char *s, int dummy, int typlen)
150154
return (result);
151155
}
152156

153-
char *
157+
char *
154158
varcharout(char *s)
155159
{
156160
char *result;

0 commit comments

Comments
 (0)