diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-09-04 18:17:47 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-09-04 20:33:36 -0400 |
commit | 9a851039aac6fc7b78a80e60699e7bd8924b6f12 (patch) | |
tree | c6b43c19fb18c48cc84084d84016635fae057871 /src/backend/utils/adt/formatting.c | |
parent | 0852006a946aa9795b4913bccebb88d623942ca6 (diff) | |
download | postgresql-9a851039aac6fc7b78a80e60699e7bd8924b6f12.tar.gz postgresql-9a851039aac6fc7b78a80e60699e7bd8924b6f12.zip |
Remove still more useless assignments.
Fix some more things scan-build pointed to as dead stores. In some of
these cases, rearranging the code a little leads to more readable
code IMO. It's all cosmetic, though.
Discussion: https://postgr.es/m/CAEudQAo1+AcGppxDSg8k+zF4+Kv+eJyqzEDdbpDg58-=MQcerQ@mail.gmail.com
Diffstat (limited to 'src/backend/utils/adt/formatting.c')
-rw-r--r-- | src/backend/utils/adt/formatting.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 9de63686ecb..bf9643ffb4a 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -6434,13 +6434,12 @@ float4_to_char(PG_FUNCTION_ARGS) int out_pre_spaces = 0, sign = 0; char *numstr, - *orgnum, *p; NUM_TOCHAR_prepare; if (IS_ROMAN(&Num)) - numstr = orgnum = int_to_roman((int) rint(value)); + numstr = int_to_roman((int) rint(value)); else if (IS_EEEE(&Num)) { if (isnan(value) || isinf(value)) @@ -6456,20 +6455,19 @@ float4_to_char(PG_FUNCTION_ARGS) } else { - numstr = orgnum = psprintf("%+.*e", Num.post, value); + numstr = psprintf("%+.*e", Num.post, value); /* * Swap a leading positive sign for a space. */ - if (*orgnum == '+') - *orgnum = ' '; - - numstr = orgnum; + if (*numstr == '+') + *numstr = ' '; } } else { float4 val = value; + char *orgnum; int numstr_pre_len; if (IS_MULTI(&Num)) @@ -6480,7 +6478,7 @@ float4_to_char(PG_FUNCTION_ARGS) Num.pre += Num.multi; } - orgnum = (char *) psprintf("%.0f", fabs(val)); + orgnum = psprintf("%.0f", fabs(val)); numstr_pre_len = strlen(orgnum); /* adjust post digits to fit max float digits */ @@ -6538,13 +6536,12 @@ float8_to_char(PG_FUNCTION_ARGS) int out_pre_spaces = 0, sign = 0; char *numstr, - *orgnum, *p; NUM_TOCHAR_prepare; if (IS_ROMAN(&Num)) - numstr = orgnum = int_to_roman((int) rint(value)); + numstr = int_to_roman((int) rint(value)); else if (IS_EEEE(&Num)) { if (isnan(value) || isinf(value)) @@ -6560,20 +6557,19 @@ float8_to_char(PG_FUNCTION_ARGS) } else { - numstr = orgnum = (char *) psprintf("%+.*e", Num.post, value); + numstr = psprintf("%+.*e", Num.post, value); /* * Swap a leading positive sign for a space. */ - if (*orgnum == '+') - *orgnum = ' '; - - numstr = orgnum; + if (*numstr == '+') + *numstr = ' '; } } else { float8 val = value; + char *orgnum; int numstr_pre_len; if (IS_MULTI(&Num)) @@ -6583,6 +6579,7 @@ float8_to_char(PG_FUNCTION_ARGS) val = value * multi; Num.pre += Num.multi; } + orgnum = psprintf("%.0f", fabs(val)); numstr_pre_len = strlen(orgnum); |