Reduce data sizes.
This commit is contained in:
@@ -36,49 +36,55 @@ mod debugging_functions {
|
||||
pub fn back_trace(ctx: NativeCallContext) -> Array {
|
||||
use crate::debugger::CallStackFrame;
|
||||
|
||||
ctx.global_runtime_state()
|
||||
.debugger
|
||||
.call_stack()
|
||||
.iter()
|
||||
.rev()
|
||||
.filter(|CallStackFrame { fn_name, args, .. }| {
|
||||
fn_name.as_str() != "back_trace" || !args.is_empty()
|
||||
})
|
||||
.map(
|
||||
|frame @ CallStackFrame {
|
||||
fn_name: _fn_name,
|
||||
args: _args,
|
||||
source: _source,
|
||||
pos: _pos,
|
||||
}| {
|
||||
let display = frame.to_string();
|
||||
if let Some(ref debugger) = ctx.global_runtime_state().debugger {
|
||||
debugger
|
||||
.call_stack()
|
||||
.iter()
|
||||
.rev()
|
||||
.filter(|CallStackFrame { fn_name, args, .. }| {
|
||||
fn_name.as_str() != "back_trace" || !args.is_empty()
|
||||
})
|
||||
.map(
|
||||
|frame @ CallStackFrame {
|
||||
fn_name: _fn_name,
|
||||
args: _args,
|
||||
source: _source,
|
||||
pos: _pos,
|
||||
}| {
|
||||
let display = frame.to_string();
|
||||
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
{
|
||||
use crate::INT;
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
{
|
||||
use crate::INT;
|
||||
|
||||
let mut map = Map::new();
|
||||
map.insert("display".into(), display.into());
|
||||
map.insert("fn_name".into(), _fn_name.into());
|
||||
if !_args.is_empty() {
|
||||
map.insert("args".into(), Dynamic::from_array(_args.clone().to_vec()));
|
||||
let mut map = Map::new();
|
||||
map.insert("display".into(), display.into());
|
||||
map.insert("fn_name".into(), _fn_name.into());
|
||||
if !_args.is_empty() {
|
||||
map.insert(
|
||||
"args".into(),
|
||||
Dynamic::from_array(_args.clone().to_vec()),
|
||||
);
|
||||
}
|
||||
if let Some(source) = _source {
|
||||
map.insert("source".into(), source.into());
|
||||
}
|
||||
if !_pos.is_none() {
|
||||
map.insert("line".into(), (_pos.line().unwrap() as INT).into());
|
||||
map.insert(
|
||||
"position".into(),
|
||||
(_pos.position().unwrap_or(0) as INT).into(),
|
||||
);
|
||||
}
|
||||
Dynamic::from_map(map)
|
||||
}
|
||||
if let Some(source) = _source {
|
||||
map.insert("source".into(), source.into());
|
||||
}
|
||||
if !_pos.is_none() {
|
||||
map.insert("line".into(), (_pos.line().unwrap() as INT).into());
|
||||
map.insert(
|
||||
"position".into(),
|
||||
(_pos.position().unwrap_or(0) as INT).into(),
|
||||
);
|
||||
}
|
||||
Dynamic::from_map(map)
|
||||
}
|
||||
#[cfg(feature = "no_object")]
|
||||
display.into()
|
||||
},
|
||||
)
|
||||
.collect()
|
||||
#[cfg(feature = "no_object")]
|
||||
display.into()
|
||||
},
|
||||
)
|
||||
.collect()
|
||||
} else {
|
||||
Array::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
use crate::module::ModuleFlags;
|
||||
use crate::plugin::*;
|
||||
use crate::{
|
||||
def_package, Dynamic, ExclusiveRange, ImmutableString, InclusiveRange, RhaiResultOf,
|
||||
SmartString, StaticVec, INT, MAX_USIZE_INT, ERR, Position
|
||||
def_package, Dynamic, ExclusiveRange, ImmutableString, InclusiveRange, Position, RhaiResultOf,
|
||||
SmartString, StaticVec, ERR, INT, MAX_USIZE_INT,
|
||||
};
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
@@ -1224,11 +1224,9 @@ mod string_functions {
|
||||
|
||||
// Check if string will be over max size limit
|
||||
if _ctx.engine().max_string_size() > 0 && len > _ctx.engine().max_string_size() {
|
||||
return Err(ERR::ErrorDataTooLarge(
|
||||
"Length of string".to_string(),
|
||||
Position::NONE,
|
||||
)
|
||||
.into());
|
||||
return Err(
|
||||
ERR::ErrorDataTooLarge("Length of string".to_string(), Position::NONE).into(),
|
||||
);
|
||||
}
|
||||
|
||||
let orig_len = string.chars().count();
|
||||
@@ -1242,11 +1240,9 @@ mod string_functions {
|
||||
|
||||
if _ctx.engine().max_string_size() > 0 && string.len() > _ctx.engine().max_string_size()
|
||||
{
|
||||
return Err(ERR::ErrorDataTooLarge(
|
||||
"Length of string".to_string(),
|
||||
Position::NONE,
|
||||
)
|
||||
.into());
|
||||
return Err(
|
||||
ERR::ErrorDataTooLarge("Length of string".to_string(), Position::NONE).into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1284,11 +1280,9 @@ mod string_functions {
|
||||
|
||||
// Check if string will be over max size limit
|
||||
if _ctx.engine().max_string_size() > 0 && len > _ctx.engine().max_string_size() {
|
||||
return Err(ERR::ErrorDataTooLarge(
|
||||
"Length of string".to_string(),
|
||||
Position::NONE,
|
||||
)
|
||||
.into());
|
||||
return Err(
|
||||
ERR::ErrorDataTooLarge("Length of string".to_string(), Position::NONE).into(),
|
||||
);
|
||||
}
|
||||
|
||||
let mut str_len = string.chars().count();
|
||||
@@ -1309,11 +1303,9 @@ mod string_functions {
|
||||
|
||||
if _ctx.engine().max_string_size() > 0 && string.len() > _ctx.engine().max_string_size()
|
||||
{
|
||||
return Err(ERR::ErrorDataTooLarge(
|
||||
"Length of string".to_string(),
|
||||
Position::NONE,
|
||||
)
|
||||
.into());
|
||||
return Err(
|
||||
ERR::ErrorDataTooLarge("Length of string".to_string(), Position::NONE).into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user