Re: refactoring - share str2*int64 functions

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: refactoring - share str2*int64 functions
Date: 2019-09-14 08:24:10
Message-ID: alpine.DEB.2.21.1909141007560.13770@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Bonjour Michaël,

> - Switching INT to use pg_strtoint32() causes a set of warnings as for
> example with AttrNumber:
> 72 | (void) pg_strtoint32(token, &local_node->fldname)
> | ^~~~~~~~~~~~~~~~~~~~~
> | |
> | AttrNumber * {aka short int *}

> And it is not like we should use a cast either, as we could hide real
> issues.

It should rather call pg_strtoint16? And possibly switch the "short int"
declaration to int16?

About batch v14: applies cleanly and compiles without warnings. "make
check" ok.

I do not think that "pg_strtoint_error" should be inlinable. The function
is unlikely to be called, so it is not performance critical to inline it,
and would enlarge the executable needlessly. However, the
"pg_strto*_check" variants should be inlinable, as you have done.

About the code, on several instances of:

/* skip leading spaces */
while (likely(*ptr) && isspace((unsigned char) *ptr)) …

I would drop the "likely(*ptr)".

And on several instances of:

!unlikely(isdigit((unsigned char) *ptr)))

ISTM that we want "unlikely(!isdigit((unsigned char) *ptr)))". Parsing
!unlikely leads to false conclusion and a headache:-)

Otherwise, this batch of changes looks ok to me.

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-09-14 09:30:02 Re: [HACKERS] [PATCH] pageinspect function to decode infomasks
Previous Message Alexander Korotkov 2019-09-14 08:14:59 Re: Psql patch to show access methods info