December 29, 2020 Re: opIndexMember | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Monday, 28 December 2020 at 20:15:27 UTC, Per Nordlöw wrote: > On Sunday, 27 December 2020 at 14:46:43 UTC, claptrap wrote: >> So basically if opIndexMember is defined for Foo then... >> >> foo[i].x >> >> Is rewritten to.. >> >> foo.opIndexMember!("x")(i); > > For an alternative solution see: > https://github.com/nordlow/phobos-next/blob/master/src/nxt/soa.d > > No benchmarks yet, tough, but you're very welcome to add them. Here's my own implementation which I dug out from an old project of mine from a few years back: https://gist.github.com/PetarKirov/a074073a12482e761a5e88eec559e5a8 |
December 29, 2020 Re: opIndexMember | ||||
---|---|---|---|---|
| ||||
Posted in reply to Petar Kirov [ZombineDev] | On Tuesday, 29 December 2020 at 22:33:01 UTC, Petar Kirov [ZombineDev] wrote:
> On Monday, 28 December 2020 at 20:15:27 UTC, Per Nordlöw wrote:
>> On Sunday, 27 December 2020 at 14:46:43 UTC, claptrap wrote:
>>> So basically if opIndexMember is defined for Foo then...
>>>
>>> foo[i].x
>>>
>>> Is rewritten to..
>>>
>>> foo.opIndexMember!("x")(i);
>>
>> For an alternative solution see:
>> https://github.com/nordlow/phobos-next/blob/master/src/nxt/soa.d
>>
>> No benchmarks yet, tough, but you're very welcome to add them.
>
> Here's my own implementation which I dug out from an old project of mine from a few years back:
>
> https://gist.github.com/PetarKirov/a074073a12482e761a5e88eec559e5a8
Comparing it to your implementation, the main advantage of mine is that it always takes (size_t.sizeof * 2) bytes, regardless of how many members the struct has since it uses a heap allocation for all of the arrays.
|
December 30, 2020 Re: opIndexMember | ||||
---|---|---|---|---|
| ||||
Posted in reply to Petar Kirov [ZombineDev] | On Tuesday, 29 December 2020 at 22:39:48 UTC, Petar Kirov [ZombineDev] wrote:
> Comparing it to your implementation, the main advantage of mine is that it always takes (size_t.sizeof * 2) bytes, regardless of how many members the struct has since it uses a heap allocation for all of the arrays.
Lots of goodies there. Thanks
|
Copyright © 1999-2021 by the D Language Foundation