Title: Remove redundant allocation in bool_input #9504
Title: Remove redundant allocation in bool_input #9504conomist wants to merge 4 commits intostarkware-libs:mainfrom
Conversation
orizi
left a comment
There was a problem hiding this comment.
@orizi made 1 comment.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @conomist).
crates/cairo-lang-test-utils/src/lib.rs line 124 at r1 (raw file):
_ if input.eq_ignore_ascii_case("false") => false, _ => panic!("Expected 'true' or 'false', actual: {input}"), }
Suggestion:
if input.eq_ignore_ascii_case("true") {
true
} else if input.eq_ignore_ascii_case("false") {
false
} else {
panic!("Expected 'true' or 'false', actual: {input}")
}
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed all commit messages and made 1 comment.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @conomist).
crates/cairo-lang-test-utils/src/lib.rs line 121 at r2 (raw file):
pub fn bool_input(input: &str) -> bool { match () { if input.eq_ignore_ascii_case("true") => true,
please fix.
orizi
left a comment
There was a problem hiding this comment.
@orizi made 1 comment.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @conomist).
crates/cairo-lang-test-utils/src/lib.rs line 121 at r2 (raw file):
Previously, orizi wrote…
please fix.
close PR if you don't plan on actually make the code compile and be well formatted.
Switch bool_input to use eq_ignore_ascii_case guards instead of lowercasing, eliminating per-call string allocation while keeping behavior unchanged