Remove some unnecessary if-condition

Поиск
Список
Период
Сортировка
От Hou, Zhijie
Тема Remove some unnecessary if-condition
Дата
Msg-id 7be3d1e817064219a929446a72f3f82b@G08CNEXMBPEKD05.g08.fujitsu.local
обсуждение исходный текст
Ответы Re: Remove some unnecessary if-condition  (Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>)
Список pgsql-hackers
Hi

I found some likely unnecessary if-condition in code.

1. Some check in else branch seems unnecessary.

In (/src/backend/replication/logical/reorderbuffer.c) 
① @@ -4068,7 +4068,7 @@ ReorderBufferToastAppendChunk(ReorderBuffer *rb, ReorderBufferTXN *txn,
> bool       found;
> if (!found)
> {
>...
> }
> else if (found && chunk_seq != ent->last_chunk_seq + 1)
>...

The check of "found" in else if branch seems unnecessary.

② (/src/backend/utils/init/postinit.c)
@@ -924,11 +924,8 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,

> bool        bootstrap = IsBootstrapProcessingMode();
> if (bootstrap)
> {
>...
> }
> else if(...)
> {...}
> else
> {
>    if (!bootstrap)
>    {
>    ...
>    }
> }

The check of "bootstrap" in else branch seems unnecessary.


2.In (/src/interfaces/ecpg/compatlib/informix.c)
@@ -944,7 +944,7 @@ rupshift(char *str)

> for (len--; str[len] && str[len] == ' '; len--);

The first "str[len]" seems unnecessary since  " str[len] == ' '" will check it as well.

Do you think we should remove these if-condition for code clean ?

Best regards,
houzj



Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "tsunakawa.takay@fujitsu.com"
Дата:
Сообщение: RE: [Patch] Optimize dropping of relation buffers using dlist
Следующее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: Expansion of our checks for connection-loss errors