Generalize .ptr to RawPtr ranges?
Dmitry Olshansky via Digitalmars-d
digitalmars-d at puremagic.com
Mon Oct 5 03:06:03 PDT 2015
Just a random idea - slices have .ptr and therefor have a bunch of
advantages such as SSE optimized copy routine.
Once I wrap a slice in something (anything) it looses ALL of that.
Now for instance std.container.Array!int.Range can easily provide .ptr
property, together with .length it would allow us to use memcpy etc.
Maybe generalize to isRandomAccessRange!Range + hasRawPtr!Range, where
hasRawPtr!(Range) would test for compatible .ptr and .length.
The benefit compared to manually slicing the .ptr and using that, then
propagating the change back to the original range is that:
- it's error prone
- awkwardly replicated at each call site
So it would be much better to retain safe range interface and
encapsulate speed-hacks inside of the algorithms.
Thoughts?
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list