ISibboI / evalexpr

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

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

Closed jbham closed 1 year ago

jbham commented 1 year 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 1 year ago

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

ISibboI commented 1 year 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 1 year ago

Done.