roxen.lists.pike.general

Subject Author Date
RE: Arrays, multisets, mappings: avoiding unnecessary memory (re)assigns Arjan van Staalduijnen <Arjan[dot]van[dot]Staalduijnen[at]rtl[dot]nl> 07-09-2009
Thanks for the answer. In short let me check if I got things right.

> In various pieces of code I am bluntly doing frequent operations such
> as:
>
> 	ids -= (< identifier >);
> or
> 	ids |= ({ identifier });
> or
> 	m_delete(ids, identifier);
>

The temporary arrays or multisets used in the examples are cause for overhead
memory assignments on their own. Avoiding these temporary assignments by first
checking through a has_value (using these examples) would be better.

For multisets there is an easy alternative using the 0 or 1. It avoids a
destructive modification all together? Has_value() not necessary in that case,
because there's no downside to the 0/1-method.

For arrays the '|=' operation is always cause for a memory copy, even if
'identifier' was already available in the array, due to the copy of the
temporary array?


Arjan