-
-
Notifications
You must be signed in to change notification settings - Fork 183
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 COW element access on transients? #122
Comments
attempting to do |
Yes, right now one has to copy the elements into a |
Which I realize, the fastest way to convert an template <typename T>
std::vector<T> to_std(const immer::vector<T>& v)
{
auto r = std::vector<T>{};
r.reserve(v.size());
immer::copy(v, std::back_inserter(v));
return r;
}
std::vector<int> to_std(const immer::vector<int>& v)
{
auto r = std::vector<int>{};
r.reserve(v.size());
immer::for_each_chunk(v, [&](auto b, auto e) {
r.insert(r.end(), b, e);
});
return r;
} I'm sure now: https://godbolt.org/z/d5n1Wj8MK |
This makes me think, maybe this is such a common thing to do that a family of |
yes that makes a lot of sense to provide the std conversion routines. I have written the Thanks also for the tip on |
it should be the resulting test result is not that ridiculous, though 1 is still slower.
|
You are right, sorry! Corrected godbolt: https://godbolt.org/z/h3cvr7qen |
This would allow to do std::sort directly saving some copies. Not sure whether it is a good idea though. There are some drawbacks.
The text was updated successfully, but these errors were encountered: