refactor: drastically simplify should_add_back_equals logic

This commit is contained in:
electria 2026-09-29 16:17:32 -07:00
commit ca9a522d2b
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -22,17 +22,12 @@ fn main() {
}
pub fn parse_and_calc_humanreadable(mut input: String) -> String {
let should_add_back_equals = if let Some((i, _)) = input
.chars()
.enumerate()
.filter(|(_, c)| !matches!(c, ' ' | '&' | '\n'))
.find(|(_, c)| *c == '=')
{
input.remove(i);
true
} else {
false
};
let should_add_back_equals = input
.find('=')
.inspect(|i| {
input.remove(*i);
})
.is_some();
// no need to remove the characters here,
// as we ignore the them in all other logic already