From 1f82ba74aa906c7b80395fad115b5d2a88421d56 Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Fri, 6 Sep 2019 23:24:39 +0000 Subject: [PATCH] Remove redundant checks in prepare_msg_raw() --- src/chat.rs | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index c245c4295..9f7802b15 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -379,21 +379,14 @@ impl<'a> Chat<'a> { let parent_in_reply_to = parent_in_reply_to.strdup(); let parent_references = parent_references.strdup(); - if !parent_rfc724_mid.is_null() - && 0 != *parent_rfc724_mid.offset(0isize) as libc::c_int - { + if 0 != *parent_rfc724_mid.offset(0isize) as libc::c_int { new_in_reply_to = dc_strdup(parent_rfc724_mid) } - if !parent_references.is_null() { - let space: *mut libc::c_char; - space = strchr(parent_references, ' ' as i32); - if !space.is_null() { - *space = 0 as libc::c_char - } + let space = strchr(parent_references, ' ' as i32); + if !space.is_null() { + *space = 0 as libc::c_char } - if !parent_references.is_null() - && 0 != *parent_references.offset(0isize) as libc::c_int - && !parent_rfc724_mid.is_null() + if 0 != *parent_references.offset(0isize) as libc::c_int && 0 != *parent_rfc724_mid.offset(0isize) as libc::c_int { new_references = dc_mprintf( @@ -401,13 +394,9 @@ impl<'a> Chat<'a> { parent_references, parent_rfc724_mid, ) - } else if !parent_references.is_null() - && 0 != *parent_references.offset(0isize) as libc::c_int - { + } else if 0 != *parent_references.offset(0isize) as libc::c_int { new_references = dc_strdup(parent_references) - } else if !parent_in_reply_to.is_null() - && 0 != *parent_in_reply_to.offset(0isize) as libc::c_int - && !parent_rfc724_mid.is_null() + } else if 0 != *parent_in_reply_to.offset(0isize) as libc::c_int && 0 != *parent_rfc724_mid.offset(0isize) as libc::c_int { new_references = dc_mprintf( @@ -415,9 +404,7 @@ impl<'a> Chat<'a> { parent_in_reply_to, parent_rfc724_mid, ) - } else if !parent_in_reply_to.is_null() - && 0 != *parent_in_reply_to.offset(0isize) as libc::c_int - { + } else if 0 != *parent_in_reply_to.offset(0isize) as libc::c_int { new_references = dc_strdup(parent_in_reply_to) } free(parent_rfc724_mid as *mut libc::c_void);