Make Engine faster to create.
This commit is contained in:
@@ -459,18 +459,26 @@ impl Engine {
|
||||
// See if the function match print/debug (which requires special processing)
|
||||
return Ok(match name {
|
||||
KEYWORD_PRINT => {
|
||||
let text = result.into_immutable_string().map_err(|typ| {
|
||||
let t = self.map_type_name(type_name::<ImmutableString>()).into();
|
||||
ERR::ErrorMismatchOutputType(t, typ.into(), pos)
|
||||
})?;
|
||||
((*self.print)(&text).into(), false)
|
||||
if let Some(ref print) = self.print {
|
||||
let text = result.into_immutable_string().map_err(|typ| {
|
||||
let t = self.map_type_name(type_name::<ImmutableString>()).into();
|
||||
ERR::ErrorMismatchOutputType(t, typ.into(), pos)
|
||||
})?;
|
||||
((print)(&text).into(), false)
|
||||
} else {
|
||||
(Dynamic::UNIT, false)
|
||||
}
|
||||
}
|
||||
KEYWORD_DEBUG => {
|
||||
let text = result.into_immutable_string().map_err(|typ| {
|
||||
let t = self.map_type_name(type_name::<ImmutableString>()).into();
|
||||
ERR::ErrorMismatchOutputType(t, typ.into(), pos)
|
||||
})?;
|
||||
((*self.debug)(&text, global.source(), pos).into(), false)
|
||||
if let Some(ref debug) = self.debug {
|
||||
let text = result.into_immutable_string().map_err(|typ| {
|
||||
let t = self.map_type_name(type_name::<ImmutableString>()).into();
|
||||
ERR::ErrorMismatchOutputType(t, typ.into(), pos)
|
||||
})?;
|
||||
((debug)(&text, global.source(), pos).into(), false)
|
||||
} else {
|
||||
(Dynamic::UNIT, false)
|
||||
}
|
||||
}
|
||||
_ => (result, is_method),
|
||||
});
|
||||
|
Reference in New Issue
Block a user