Skip to content

Commit

Permalink
Move executor into FeedUpdate struct.
Browse files Browse the repository at this point in the history
This avoids recreating it for every nasl file, improving performance by
15%.
  • Loading branch information
Tehforsch committed Jan 7, 2025
1 parent ab03959 commit 9b38a23
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rust/src/feed/update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::nasl::nasl_std_functions;
use crate::nasl::prelude::*;
use crate::nasl::syntax::AsBufReader;
use crate::nasl::utils::context::Target;
use crate::nasl::utils::Executor;
use crate::nasl::ContextType;
use crate::storage::{item::NVTField, ContextKey, Dispatcher, NoOpRetriever};

Expand All @@ -37,6 +38,7 @@ pub struct Update<'a, S, L, V> {
max_retry: usize,
verifier: V,
feed_version_set: bool,
executor: Executor,
}

/// Loads the plugin_feed_info and returns the feed version
Expand Down Expand Up @@ -106,6 +108,7 @@ where
dispatcher: storage,
verifier,
feed_version_set: false,
executor: nasl_std_functions(),
}
}

Expand Down Expand Up @@ -149,14 +152,13 @@ where
let register = Register::root_initial(&self.initial);
let fr = NoOpRetriever::default();
let target = Target::default();
let functions = nasl_std_functions();
let context = Context::new(
key.clone(),
target,
self.dispatcher,
&fr,
self.loader,
&functions,
&self.executor,
);
let mut results = Box::pin(CodeInterpreter::new(&code, register, &context).stream());
while let Some(stmt) = results.next().await {
Expand Down

0 comments on commit 9b38a23

Please sign in to comment.