Fix Array::chop.
This commit is contained in:
parent
96764c0d2d
commit
e2e0b8d083
@ -8,6 +8,7 @@ Bug fixes
|
||||
---------
|
||||
|
||||
* Padding arrays with another array via `pad` no longer loops indefinitely.
|
||||
* `chop` for arrays and BLOB's now works properly.
|
||||
* `set_bit` for bit-flags with negative index now works correctly.
|
||||
* Misnamed `params` field `name` in the JSON output of `Engine::gen_fn_metadata_to_json` is fixed (was incorrectly named `type`).
|
||||
|
||||
|
@ -171,11 +171,11 @@ pub mod array_functions {
|
||||
}
|
||||
}
|
||||
pub fn chop(array: &mut Array, len: INT) {
|
||||
if !array.is_empty() && len as usize >= array.len() {
|
||||
if len >= 0 {
|
||||
array.drain(0..array.len() - len as usize);
|
||||
} else {
|
||||
if !array.is_empty() {
|
||||
if len <= 0 {
|
||||
array.clear();
|
||||
} else if (len as usize) < array.len() {
|
||||
array.drain(0..array.len() - len as usize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,11 +162,11 @@ pub mod blob_functions {
|
||||
}
|
||||
}
|
||||
pub fn chop(blob: &mut Blob, len: INT) {
|
||||
if !blob.is_empty() && len as usize >= blob.len() {
|
||||
if len >= 0 {
|
||||
blob.drain(0..blob.len() - len as usize);
|
||||
} else {
|
||||
if !blob.is_empty() {
|
||||
if len <= 0 {
|
||||
blob.clear();
|
||||
} else if (len as usize) < blob.len() {
|
||||
blob.drain(0..blob.len() - len as usize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user