Move BLOB concat and push to builtin.
This commit is contained in:
@@ -61,12 +61,12 @@ mod blob_functions {
|
||||
pub fn len(blob: &mut Blob) -> INT {
|
||||
blob.len() as INT
|
||||
}
|
||||
#[rhai_fn(name = "push", name = "+=")]
|
||||
#[rhai_fn(name = "push")]
|
||||
pub fn push(blob: &mut Blob, item: INT) {
|
||||
let item = (item & 0x00ff) as u8;
|
||||
blob.push(item);
|
||||
}
|
||||
#[rhai_fn(name = "append", name = "+=")]
|
||||
#[rhai_fn(name = "append")]
|
||||
pub fn append(blob: &mut Blob, y: Blob) {
|
||||
if !y.is_empty() {
|
||||
if blob.is_empty() {
|
||||
@@ -76,17 +76,6 @@ mod blob_functions {
|
||||
}
|
||||
}
|
||||
}
|
||||
#[rhai_fn(name = "+")]
|
||||
pub fn concat(mut blob: Blob, y: Blob) -> Blob {
|
||||
if !y.is_empty() {
|
||||
if blob.is_empty() {
|
||||
blob = y;
|
||||
} else {
|
||||
blob.extend(y);
|
||||
}
|
||||
}
|
||||
blob
|
||||
}
|
||||
pub fn insert(blob: &mut Blob, position: INT, item: INT) {
|
||||
let item = (item & 0x00ff) as u8;
|
||||
|
||||
@@ -211,7 +200,7 @@ mod blob_functions {
|
||||
.checked_abs()
|
||||
.map_or(0, |n| blob_len - (n as usize).min(blob_len))
|
||||
} else if start as usize >= blob_len {
|
||||
blob.extend(replace.into_iter());
|
||||
blob.extend(replace);
|
||||
return;
|
||||
} else {
|
||||
start as usize
|
||||
|
Reference in New Issue
Block a user