Reduce call to Module::is_empty.
This commit is contained in:
@@ -57,12 +57,11 @@ impl fmt::Debug for AST {
|
||||
fp.field("body", &self.body.as_slice());
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
if !self.lib.is_empty() {
|
||||
for (.., fn_def) in self.lib.iter_script_fn() {
|
||||
let sig = fn_def.to_string();
|
||||
fp.field(&sig, &fn_def.body.as_slice());
|
||||
}
|
||||
for (.., fn_def) in self.lib.iter_script_fn() {
|
||||
let sig = fn_def.to_string();
|
||||
fp.field(&sig, &fn_def.body.as_slice());
|
||||
}
|
||||
|
||||
fp.finish()
|
||||
}
|
||||
}
|
||||
@@ -231,23 +230,6 @@ impl AST {
|
||||
pub(crate) fn set_doc(&mut self, doc: impl Into<crate::SmartString>) {
|
||||
self.doc = doc.into();
|
||||
}
|
||||
/// Get the shared [module][crate::Module] containing script-defined functions.
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
#[cfg(not(feature = "internals"))]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub(crate) fn functions(&self) -> &crate::SharedModule {
|
||||
&self.lib
|
||||
}
|
||||
/// _(internals)_ Get the shared [module][crate::Module] containing script-defined functions.
|
||||
/// Exported under the `internals` feature only.
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
#[cfg(feature = "internals")]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn functions(&self) -> &crate::SharedModule {
|
||||
&self.lib
|
||||
}
|
||||
/// Get the statements.
|
||||
#[cfg(not(feature = "internals"))]
|
||||
#[inline(always)]
|
||||
@@ -756,7 +738,7 @@ impl AST {
|
||||
&mut self,
|
||||
filter: impl Fn(FnNamespace, FnAccess, &str, usize) -> bool,
|
||||
) -> &mut Self {
|
||||
if !self.lib.is_empty() {
|
||||
if self.has_functions() {
|
||||
crate::func::shared_make_mut(&mut self.lib).retain_script_functions(filter);
|
||||
}
|
||||
self
|
||||
|
Reference in New Issue
Block a user