Re: [PATCH RFC 01/24] ref-filter: get rid of goto

2 messages, 2 authors, 2018-01-31 · open the first message on its own page

Re: [PATCH RFC 01/24] ref-filter: get rid of goto

From: Junio C Hamano <hidden>
Date: 2018-01-30 20:50:03

Оля Тележная  [off-list ref] writes:
quoted
one place improves readability.  If better readability is the
purpose, I would even say

         for (i = 0; i < used_atom_cnt; i++) {
                if (...)
-                       goto need_obj;
+                       break;
        }
-       return;
+       if (used_atom_cnt <= i)
                return;

-need_obj:

would make the result easier to follow with a much less impact.
It's hard for me to read the code with goto, and as I know, it's not
only my problem,...
That sounds as if you are complaining "I wanted to get rid of goto
and you tell me not to do so???", but read what I showed above again
and notice that it is also getting rid of "goto".

The main difference from your version is that the original function
is still kept as a single unit of work, instead of two.

Re: [PATCH RFC 01/24] ref-filter: get rid of goto

From: Оля Тележная <hidden>
Date: 2018-01-31 06:39:57

2018-01-30 23:49 GMT+03:00 Junio C Hamano [off-list ref]:
Оля Тележная  [off-list ref] writes:
quoted
quoted
one place improves readability.  If better readability is the
purpose, I would even say

         for (i = 0; i < used_atom_cnt; i++) {
                if (...)
-                       goto need_obj;
+                       break;
        }
-       return;
+       if (used_atom_cnt <= i)
                return;

-need_obj:

would make the result easier to follow with a much less impact.
It's hard for me to read the code with goto, and as I know, it's not
only my problem,...
That sounds as if you are complaining "I wanted to get rid of goto
and you tell me not to do so???", but read what I showed above again
and notice that it is also getting rid of "goto".
No, I am not complaining. I tried to explain why I did everything that
way. Sorry if it was not clear enough.
The main difference from your version is that the original function
is still kept as a single unit of work, instead of two.
And I am not sure that it is good, the function is too big and it
actually does so many different separate pieces. If it is possible to
shorten long function by getting some separate logic (that's our case,
we do not request object until that final goto statement), I think
it's good idea and we need to do so and simplify future reading. But,
if you do not agree with this fact, please explain your position in
detail, and I will change that place as you want.

Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help