Change parameter name.

This commit is contained in:
Stephen Chung 2021-11-23 18:10:01 +08:00
parent 2e9807b172
commit 0c89a9c4c5
3 changed files with 9 additions and 10 deletions

View File

@ -69,7 +69,7 @@ mod array_functions {
} }
#[rhai_fn(return_raw)] #[rhai_fn(return_raw)]
pub fn pad( pub fn pad(
_ctx: NativeCallContext, ctx: NativeCallContext,
array: &mut Array, array: &mut Array,
len: INT, len: INT,
item: Dynamic, item: Dynamic,
@ -78,6 +78,8 @@ mod array_functions {
return Ok(()); return Ok(());
} }
let _ctx = ctx;
// Check if array will be over max size limit // Check if array will be over max size limit
#[cfg(not(feature = "unchecked"))] #[cfg(not(feature = "unchecked"))]
if _ctx.engine().max_array_size() > 0 && (len as usize) > _ctx.engine().max_array_size() { if _ctx.engine().max_array_size() > 0 && (len as usize) > _ctx.engine().max_array_size() {

View File

@ -30,11 +30,12 @@ mod blob_functions {
} }
#[rhai_fn(name = "blob", return_raw)] #[rhai_fn(name = "blob", return_raw)]
pub fn blob_with_capacity_and_value( pub fn blob_with_capacity_and_value(
_ctx: NativeCallContext, ctx: NativeCallContext,
len: INT, len: INT,
value: INT, value: INT,
) -> Result<Blob, Box<EvalAltResult>> { ) -> Result<Blob, Box<EvalAltResult>> {
let len = if len < 0 { 0 } else { len as usize }; let len = if len < 0 { 0 } else { len as usize };
let _ctx = ctx;
// Check if blob will be over max size limit // Check if blob will be over max size limit
#[cfg(not(feature = "unchecked"))] #[cfg(not(feature = "unchecked"))]
@ -46,11 +47,8 @@ mod blob_functions {
.into()); .into());
} }
let value = (value & 0x000f) as u8; let mut blob = Blob::new();
let mut blob = Blob::with_capacity(len); blob.resize(len, (value & 0x000f) as u8);
for _ in 0..len {
blob.push(value);
}
Ok(blob) Ok(blob)
} }
#[rhai_fn(name = "len", get = "len", pure)] #[rhai_fn(name = "len", get = "len", pure)]
@ -106,7 +104,7 @@ mod blob_functions {
} }
#[rhai_fn(return_raw)] #[rhai_fn(return_raw)]
pub fn pad( pub fn pad(
_ctx: NativeCallContext, ctx: NativeCallContext,
blob: &mut Blob, blob: &mut Blob,
len: INT, len: INT,
item: INT, item: INT,
@ -116,6 +114,7 @@ mod blob_functions {
} }
let item = (item & 0x000f) as u8; let item = (item & 0x000f) as u8;
let _ctx = ctx;
// Check if blob will be over max size limit // Check if blob will be over max size limit
#[cfg(not(feature = "unchecked"))] #[cfg(not(feature = "unchecked"))]

View File

@ -469,7 +469,6 @@ mod string_functions {
if len <= 0 { if len <= 0 {
return Ok(()); return Ok(());
} }
let _ctx = ctx; let _ctx = ctx;
// Check if string will be over max size limit // Check if string will be over max size limit
@ -514,7 +513,6 @@ mod string_functions {
if len <= 0 { if len <= 0 {
return Ok(()); return Ok(());
} }
let _ctx = ctx; let _ctx = ctx;
// Check if string will be over max size limit // Check if string will be over max size limit