-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Context::get_value_cow() #104
base: main
Are you sure you want to change the base?
Conversation
Thanks, this looks interesting. I think though that it is better if there is just one This will make it harder to implement a custom context though, so the Could you make the required changes? |
Thanks for the reply, I pushed the new idea, I hope I understood it correctly. |
92142c6
to
1e41c13
Compare
Hi, sorry, so I think there was a misunderstanding. I would prefer having a function So only have a function that returns a Cow. |
Sorry for the delay, GitHub notifications weren't reaching me. I'm making the change to use
So the |
e4a8571
to
6608b16
Compare
We are trying to use evalexpr, but a small missing detail is preventing us from using it effectively.
The way the contract of
Context
is defined,get_value()
is forced to return a reference to a value it owns, but in our case we'd like to return a computed value without holding on to it.Specifically, we want to iterate over a whole table of data, and each row we visit should be another "context" for the expression. With the current design we're forced to create an ephemeral hash map on each iteration step and fill it with the values. This becomes the bottleneck of the overall computation.
Our proposed change is to introduce a new method to
Context
,get_value_cow()
, which returns aCow
and thus covers both the owned and the referenced cases. This would be a non-breaking change becauseget_value_cow()
comes with a default implementation that delegates to the existingget_value()
. Here's how it looks for our implementation: