From 4ec5e5af47e5610aa592e93d3eedc10cdb56b88e Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Wed, 30 Apr 2014 23:23:06 +0000 Subject: [PATCH] Refactor if blocks Since the first branch doesn't need to do anything, we invert it and pull a sub-branch out a level into the main conditional. --- src/switch_core_media.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/switch_core_media.c b/src/switch_core_media.c index a5cb29022c..f007a8e3ee 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -3038,21 +3038,16 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s switch_channel_set_variable(session->channel, "media_audio_mode", NULL); } - - if (switch_media_handle_test_media_flag(smh, SCMF_DISABLE_HOLD) || - ((val = switch_channel_get_variable(session->channel, "rtp_disable_hold")) && switch_true(val))) { - } else { - - if (!smh->mparams->hold_laps) { - smh->mparams->hold_laps++; - if (switch_core_media_toggle_hold(session, sendonly)) { - reneg = switch_media_handle_test_media_flag(smh, SCMF_RENEG_ON_HOLD); - - if ((val = switch_channel_get_variable(session->channel, "rtp_renegotiate_codec_on_hold"))) { - reneg = switch_true(val); - } + if (!(switch_media_handle_test_media_flag(smh, SCMF_DISABLE_HOLD) + || ((val = switch_channel_get_variable(session->channel, "rtp_disable_hold")) + && switch_true(val))) + && !smh->mparams->hold_laps) { + smh->mparams->hold_laps++; + if (switch_core_media_toggle_hold(session, sendonly)) { + reneg = switch_media_handle_test_media_flag(smh, SCMF_RENEG_ON_HOLD); + if ((val = switch_channel_get_variable(session->channel, "rtp_renegotiate_codec_on_hold"))) { + reneg = switch_true(val); } - } }