I've been working with my own language again, and have noticed a significant
speedup when I inlined message arguments into a flat array. There is then
logic to create a dynamic array if greater than 5 items.
For example, looking at Io's source:
typedef struct
{
IoSymbol *name;
//List *args;
IoMessage *next;
ArgList args; // args is never shared nor repointed
} IoMessageData;
List *IoMessage_args(IoMessage *self)
{
//return DATA(self)->args;
return &DATA(self)->args; // Keeps list local to obj
}
Another approach is to allocate a list and it's items together, and allocate
more space than the size of the struct:
typedef struct
{
//void **items;
size_t size;
size_t memSize;
void *items[5];
} ArgList;
Granted you can't resize the list without changing the address of the list. If
this structure was considered non-mutable, I believe it could work.
...just some random thoughts :)
Mike