Ticket #1861 (closed defect: duplicate)
just a try to simplify
Reported by: | vit_r | Owned by: | vit_r |
---|---|---|---|
Priority: | trivial | Milestone: | 4.7 |
Component: | mc-skin | Version: | 4.7.0-pre4 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Branch state: | Votes for changeset: |
Description
just a try to simplify what is it about
(keeping in the mind: the upper judge is the Author)
if (groups == NULL || *groups == NULL) { if (groups != NULL) g_strfreev (groups); return FALSE; }
preserving and clarifying the most possible meaning
with practical result as upper judge
Attachments
Change History
Changed 15 years ago by vit_r
- Attachment 1861-rearranging-some-lines-in-src_skin_colors.c.patch added
comment:1 follow-up: ↓ 2 Changed 15 years ago by andrew_b
No need 'else' after 'return' or 'continue'.
comment:2 in reply to: ↑ 1 ; follow-up: ↓ 3 Changed 15 years ago by vit_r
Replying to andrew_b:
No need 'else' after 'return' or 'continue'.
If it is a question then my answer is such:
"Original lines have no more checks
Rewritten lines should perform exactly the same checks but in more stable way.
Would be in next line "*groups == NULL' checked before 'groups == NULL'
if (groups == NULL || *groups == NULL) {a crash(seg.fault) would happen.
But in rearranged(new) version such crash can _NOT_ happen because
'groups == NULL' is firstly checked always.
So: If there is compiler checking from right to left
(i don't know such compiler really)
cited line can crash.
isn't so?
One more advantage(if i will not say may be nobody will say..)
Now they are much more beautiful ... , aren't they ?"
comment:3 in reply to: ↑ 2 ; follow-up: ↓ 4 Changed 15 years ago by andrew_b
Replying to vit_r:
So: If there is compiler checking from right to left
(i don't know such compiler really)
cited line can crash.
isn't so?
The ISO/IEC 9899:1999 standard:
6.5.13. Unlike the bitwise binary & operator, the && operator guarantees left-to-right evaluation; there is a sequence point after the evaluation of the first operand. If the first operand compares equal to 0, the second operand is not evaluated. 6.5.14 Unlike the bitwise | operator, the || operator guarantees left-to-right evaluation; there is a sequence point after the evaluation of the first operand. If the first operand compares unequal to 0, the second operand is not evaluated.