From b56d088fb25ea1caa6814f6fd87f348c60db967e Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 5 Nov 2023 20:29:48 +0800 Subject: [PATCH] feat: optimize naming --- src/msg.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/msg.rs b/src/msg.rs index ced0027..4fc9896 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -203,33 +203,25 @@ pub fn get_room_message_type(first_part: &str) -> XResult { fn parse_message_parts(msg: &str) -> Vec { let mut msg_parts = vec![]; let mut in_quote = false; - let mut is_back_slash = false; + let mut is_last_char_back_slash = false; let mut last_part = vec![]; for c in msg.chars().skip(1) { - if is_back_slash { + if is_last_char_back_slash { last_part.push(c); - is_back_slash = false; + is_last_char_back_slash = false; continue; } match c { - ' ' if in_quote => { - last_part.push(c); - } + ' ' if in_quote => { last_part.push(c); } ' ' => { if !last_part.is_empty() { msg_parts.push(last_part.iter().collect::()); last_part.clear(); } } - '\\' => { - is_back_slash = true; - } - '\'' => { - in_quote = !in_quote; - } - _ => { - last_part.push(c); - } + '\\' => { is_last_char_back_slash = true; } + '\'' => { in_quote = !in_quote; } + _ => { last_part.push(c); } } } if !last_part.is_empty() {