ISibboI / evalexpr

A powerful expression evaluation crate 🦀.
GNU Affero General Public License v3.0
320 stars 52 forks source link

Added clear method on HashMapContext's variables and functions fields. #156

Closed jbham closed 11 months ago

jbham commented 11 months ago

I've the below use case where numerous allocations are happening and hoping to reduce the impact of those re-allocations using the clear method on the fields of HashMapContext:

There are 1000s of transactions with each transaction having about 40 fields. Let's say field 5 and field 30 are sent from source as optional Boolean type (Option<bool>), which would mean certain transaction could have a boolean value and other transactions would have null value. I cannot use a default boolean value here. Since once the HashMapContext variables are created, their types can no longer be changed. Therefore, I have re-initiate the HashMapContext let mut context = HashMapContext::new(); after every transaction and does the re-allocation.

jbham commented 11 months ago

@ISibboI FYI and thank you for the great library :)

ISibboI commented 11 months ago

Great, thanks! Could you update the pull request to include the most recent changes to main? I just ignored that lint that made beta and nightly fail.

jbham commented 11 months ago

Done.