4 ms·
Hundreds at the moment, but it will need to scale to thousands. Complexity varies, it's usually a bunch of ORs but technically the complexity can be arbitrary
by secondcoming 3y ago
Hundreds at the moment, but it will need to scale to thousands.
Complexity varies, it's usually a bunch of ORs but technically the complexity can be arbitrary as they're created by humans.
Recursion comes from the AST structure. For example, for an AND operation it's essentially
bool execute(ANDNode n) { return execute(n->left) && execute(n->right); }
In reality it's the visitor pattern using variants. That's what I want to get away from.
- DylanSp 3y agoSo it sounds like the rules themselves aren't recursive, just your current strategy for evaluating them; is that correct? Given that, I'm more inclined towards the currently upvoted reply about translating them to JS/Lua and just calling eval(). [1] It'd be very simple and _should_ be fast enough, though you might need to worry a little bit about security (especially depending on whoever's providing the rule sets and how much validation there is around them). [1] https://news.ycombinator.com/item?id=37136272 https://news.ycombinator.com/item?id=37136272