empty bytestring should return 0 not 1

This commit is contained in:
Kasey White 2022-09-23 04:09:28 -04:00
parent 9b6d4e20c7
commit c45643bb01
1 changed files with 7 additions and 1 deletions

View File

@ -457,7 +457,13 @@ impl Value {
((i.abs() as f64).log2().floor() as i64 / 64) + 1 ((i.abs() as f64).log2().floor() as i64 / 64) + 1
} }
} }
Constant::ByteString(b) => (((b.len() as i64 - 1) / 8) + 1), Constant::ByteString(b) => {
if b.is_empty() {
0
} else {
((b.len() as i64 - 1) / 8) + 1
}
}
Constant::String(s) => s.chars().count() as i64, Constant::String(s) => s.chars().count() as i64,
Constant::Unit => 1, Constant::Unit => 1,
Constant::Bool(_) => 1, Constant::Bool(_) => 1,