optimize logic in masking variables and numbers

This commit is contained in:
Simon Gardling 2022-05-07 03:04:34 -04:00
parent 6eee88bb05
commit c283d29bae

View File

@ -123,25 +123,19 @@ pub fn split_function_chars(chars: &[char]) -> Vec<String> {
// Set data about current character // Set data about current character
let mut curr_c = BoolSlice::from_char(c, prev_char.masked_num, prev_char.masked_var); let mut curr_c = BoolSlice::from_char(c, prev_char.masked_num, prev_char.masked_var);
// If previous char was a masked number, and current char is a number, mask current char's variable status
if prev_char.masked_num && curr_c.number { if prev_char.masked_num && curr_c.number {
// If previous char was a masked number, and current char is a number, mask current char's variable status
curr_c.masked_num = true; curr_c.masked_num = true;
} } else if prev_char.masked_var && curr_c.variable {
// If previous char was a masked variable, and current char is a variable, mask current char's variable status
// If previous char was a masked variable, and current char is a variable, mask current char's variable status
if prev_char.masked_var && curr_c.variable {
curr_c.masked_var = true; curr_c.masked_var = true;
} } else if prev_char.letter && !prev_char.is_variable() {
// If letter and not a variable (or a masked variable)
// If letter and not a variable (or a masked variable)
if prev_char.letter && !prev_char.is_variable() {
// Mask number status if current char is number
if curr_c.number { if curr_c.number {
// Mask number status if current char is number
curr_c.masked_num = true; curr_c.masked_num = true;
} } else if curr_c.variable {
// Mask variable status if current char is a variable
// Mask variable status if current char is a variable
if curr_c.variable {
curr_c.masked_var = true; curr_c.masked_var = true;
} }
} }