-
-
Notifications
You must be signed in to change notification settings - Fork 705
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
std.container.InlinedArray #9936
Labels
Comments
daniel350 commented on 2012-08-15T06:30:37ZThis is a very cool idea.
The concept put simply is just your typical dynamic array with a pre-allocated buffer that it *can* use up until it surpasses that buffer, in which case that buffer is then ignored (at the cost of the size of the buffer, which is probably negligible in most cases).
The only problems I can foresee is perhaps little 'gotchas' in that union of a dynamic array and static array. I'd have to investigate to know for sure on that.
Lots of unit tests for this I think, and definitely some information needed from those in the know about the compiler back end. |
dmitry.olsh (@DmitryOlshansky) commented on 2012-08-15T11:35:56ZThis is called small array optimization except for size of array is hardwired so that the whole struct fits a couple of words. I suggest to just add it to std.container.Array. |
bearophile_hugs commented on 2012-08-15T15:34:34Z(In reply to comment #2)
> This is called small array optimization except for size of array is hardwired
> so that the whole struct fits a couple of words. I suggest to just add it to
> std.container.Array.
Yes, this is similar to small array optimization, but this variant of the idea allows you to tune how much space you want to save locally.
Beside staticLen, this InlinedArray also optionally takes the Tlen type. If you are using something very small, like ubytes or chars or shorts, and you want to pack as many of them as possible in the local static array, you are allowed to define Tlen as ubyte (or ushort) instead of uint or size_t. So InlinedArray!(int,1) takes 12 bytes and stores up to 11 ubytes/chars. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bearophile_hugs reported this on 2012-08-15T06:09:32Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=8550
CC List
Description
The text was updated successfully, but these errors were encountered: