Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid side-effectful assignments in conditionals. #984

Merged
merged 1 commit into from
Jul 8, 2018

Conversation

iphydf
Copy link
Member

@iphydf iphydf commented Jul 8, 2018

Only in audio.c for now. This should be done everywhere.


This change is Reviewable

@iphydf iphydf added this to the v0.2.x milestone Jul 8, 2018
@iphydf iphydf force-pushed the no-cond-side-effects branch 4 times, most recently from e5a0004 to 57faf61 Compare July 8, 2018 19:17
@iphydf iphydf assigned sudden6 and unassigned zoff99 Jul 8, 2018
Only in audio.c for now. This should be done everywhere.
Copy link

@sudden6 sudden6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 2 files at r1.
Reviewable status: 0 of 1 LGTMs obtained (waiting on @sudden6)


toxav/audio.c, line 149 at r1 (raw file):

    struct RTPMessage *msg = jbuf_read(j_buf, &rc);

    for (; msg != nullptr || rc == 2; msg = jbuf_read(j_buf, &rc)) {

any special reason not to use a while loop here and move the msg = ... into the body?

Copy link
Member Author

@iphydf iphydf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 LGTMs obtained (waiting on @sudden6)


toxav/audio.c, line 149 at r1 (raw file):

Previously, sudden6 wrote…

any special reason not to use a while loop here and move the msg = ... into the body?

Because this is a "for-each-element-in-jitter-buffer" loop, so the "for" keyword makes the most sense. Did I miss something?

Copy link

@sudden6 sudden6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm_strong:

Reviewed 1 of 2 files at r1.
Reviewable status: :shipit: complete! 1 of 1 LGTMs obtained


toxav/audio.c, line 149 at r1 (raw file):

Previously, iphydf wrote…

Because this is a "for-each-element-in-jitter-buffer" loop, so the "for" keyword makes the most sense. Did I miss something?

just wanted to know the reason, because for me this structure always looks incomplete and I would use a while loop here to make the loop header as short as possible. Just personal preference in the end, no need to change it.

Copy link

@sudden6 sudden6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm_strong:

Reviewable status: :shipit: complete! 1 of 1 LGTMs obtained

@iphydf iphydf merged commit c0c3098 into TokTok:master Jul 8, 2018
@iphydf iphydf deleted the no-cond-side-effects branch July 8, 2018 22:02
@iphydf iphydf modified the milestones: v0.2.x, v0.2.4 Jul 16, 2018
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants