Skip to content

Static BinaryOperator HashMap #21

@linuskmr

Description

@linuskmr

This HashMap should be static to avoid creating it for every comparison of BinaryOperator.

fortytwo-lang/src/ast.rs

Lines 167 to 173 in d1d81e1

let mut precedence = HashMap::new();
precedence.insert(BinaryOperator::Less, 10);
precedence.insert(BinaryOperator::Greater, 10);
precedence.insert(BinaryOperator::Add, 20);
precedence.insert(BinaryOperator::Subtract, 20);
precedence.insert(BinaryOperator::Multiply, 30);
precedence.insert(BinaryOperator::Divide, 30);

Maybe use lazy_static.

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactoringChanges to code structure without changing the output

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions