Skip to content
Prev Previous commit
Next Next commit
Make loop simple with `slice::contains
Co-authored-by: Jeong YunWon <69878+youknowone@users.noreply.github.com>
  • Loading branch information
moreal and youknowone committed Aug 13, 2022
commit 879ed6e005cb98188051b13148d9599f26974f69
10 changes: 4 additions & 6 deletions vm/src/stdlib/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,10 @@ mod builtins {
let code = match source {
Either::A(either) => {
let source: &[u8] = &either.borrow_bytes();
for x in source {
if *x == 0 {
return Err(vm.new_value_error(
"source code string cannot contain null bytes".to_owned(),
));
}
if source.contains(&0) {
return Err(vm.new_value_error(
"source code string cannot contain null bytes".to_owned(),
));
}

match std::str::from_utf8(source) {
Expand Down