On 2013-02-02 19:01, Namespace wrote:
Example:

struct Color {
public:
     ubyte[4] colors;
}

ubyte[] data = new ubyte[color_data.length * 4]; // enough storage
foreach (ref const Color col; color_data) {
     data ~= col.colors;
}

Sorry, but what is the point of data having only 4 bytes reserved
at the beginning? What is wrong with this:

    ubyte[] data;
    data.reserve(color_data.length * 4);
    foreach (ref const Color col; color_data)
        data ~= col.colors;

Are you uncomfortable, because it may allocate twice as much space
as you need (for bigger color_data)?

Reply via email to