On 8 December 2016 at 15:54, Aleksander Alekseev <a.aleks...@postgrespro.ru> wrote: > Hi. > > I noticed that there is a lot of repeating code like this: > > ``` > if (strspn(str, " \t\n\r\f") == strlen(str)) > ``` > > I personally don't find it particularly readable, not mentioning that > traversing a string twice doesn't look as a good idea (you can check > using objdump that latest GCC 6.2 doesn't optimize this code).
You could just change it to if (str[strspn(str, " \t\n\r\f")] == '\0') to mitigate calling strlen. It's safe to do so because strspn will only return values from 0 to strlen(str). Geoff -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers