diff --git a/src/packages/array_basic.rs b/src/packages/array_basic.rs index 39665b99..75c750b2 100644 --- a/src/packages/array_basic.rs +++ b/src/packages/array_basic.rs @@ -69,7 +69,7 @@ mod array_functions { } #[rhai_fn(return_raw)] pub fn pad( - _ctx: NativeCallContext, + ctx: NativeCallContext, array: &mut Array, len: INT, item: Dynamic, @@ -78,6 +78,8 @@ mod array_functions { return Ok(()); } + let _ctx = ctx; + // Check if array will be over max size limit #[cfg(not(feature = "unchecked"))] if _ctx.engine().max_array_size() > 0 && (len as usize) > _ctx.engine().max_array_size() { diff --git a/src/packages/blob_basic.rs b/src/packages/blob_basic.rs index 22a229fa..ca0e6683 100644 --- a/src/packages/blob_basic.rs +++ b/src/packages/blob_basic.rs @@ -30,11 +30,12 @@ mod blob_functions { } #[rhai_fn(name = "blob", return_raw)] pub fn blob_with_capacity_and_value( - _ctx: NativeCallContext, + ctx: NativeCallContext, len: INT, value: INT, ) -> Result> { let len = if len < 0 { 0 } else { len as usize }; + let _ctx = ctx; // Check if blob will be over max size limit #[cfg(not(feature = "unchecked"))] @@ -46,11 +47,8 @@ mod blob_functions { .into()); } - let value = (value & 0x000f) as u8; - let mut blob = Blob::with_capacity(len); - for _ in 0..len { - blob.push(value); - } + let mut blob = Blob::new(); + blob.resize(len, (value & 0x000f) as u8); Ok(blob) } #[rhai_fn(name = "len", get = "len", pure)] @@ -106,7 +104,7 @@ mod blob_functions { } #[rhai_fn(return_raw)] pub fn pad( - _ctx: NativeCallContext, + ctx: NativeCallContext, blob: &mut Blob, len: INT, item: INT, @@ -116,6 +114,7 @@ mod blob_functions { } let item = (item & 0x000f) as u8; + let _ctx = ctx; // Check if blob will be over max size limit #[cfg(not(feature = "unchecked"))] diff --git a/src/packages/string_more.rs b/src/packages/string_more.rs index 59aae414..e7cdfee4 100644 --- a/src/packages/string_more.rs +++ b/src/packages/string_more.rs @@ -469,7 +469,6 @@ mod string_functions { if len <= 0 { return Ok(()); } - let _ctx = ctx; // Check if string will be over max size limit @@ -514,7 +513,6 @@ mod string_functions { if len <= 0 { return Ok(()); } - let _ctx = ctx; // Check if string will be over max size limit