On 2/7/2014 1:13 AM, Walter Bright wrote:
On 2/7/2014 12:46 AM, Brad Anderson wrote:
Why not just stick the stack array in ScopeBuffer itself (the
size could be a template parameter)?
1. It's set up to fit into two registers on 64 bit code. This means it can be
passed/returned from functions in registers. When I used this in my own code,
high speed was the top priority, and this made a difference.
2. It needs to avoid the default initialization of the array, because it's both
unnecessary and it kills the speed. Currently, this
cannot be avoided for part of a struct.
3. I wanted it to be usable for any block of memory the user wished to dedicate
to be a buffer.
4. Having an internal reference like that would mean a postblit is required for
copying/moving the range, another source of speed degradation.
5. Every instantiation that only differs by the buffer size would generate a
separate set of code. Having the buffer size passed into the constructor means
only one instance is generated per type.