Skip to content

Commit

Permalink
refacto: use static str for key of modules
Browse files Browse the repository at this point in the history
There is no need to allocate a string for this key.
  • Loading branch information
vthib committed Jul 28, 2024
1 parent 78435bb commit 1b8013b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions boreal/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct Compiler {
/// Modules declared in the compiler, added with [`Compiler::add_module`].
///
/// These are modules that can be imported and used in the namespaces.
available_modules: HashMap<String, AvailableModule>,
available_modules: HashMap<&'static str, AvailableModule>,

/// List of imported modules, passed to the scanner.
imported_modules: Vec<Box<dyn crate::module::Module>>,
Expand Down Expand Up @@ -163,7 +163,7 @@ impl Compiler {
pub fn add_module<M: crate::module::Module + 'static>(&mut self, module: M) -> bool {
let m = module::compile_module(&module);

match self.available_modules.entry(m.name.to_owned()) {
match self.available_modules.entry(m.name) {
Entry::Occupied(_) => false,
Entry::Vacant(v) => {
let _r = v.insert(AvailableModule {
Expand Down Expand Up @@ -322,7 +322,7 @@ impl Compiler {
self.add_rules_file_inner(&path, namespace_name, status)?;
}
YaraFileComponent::Import(import) => {
match self.available_modules.get_mut(&import.name) {
match self.available_modules.get_mut(&*import.name) {
Some(module) => {
// XXX: this is a bit ugly, but i haven't found a better way to get
// ownership of the module.
Expand Down

0 comments on commit 1b8013b

Please sign in to comment.