(re)assigns
On Mon, 7 Sep 2009, Henrik Grubbström wrote:
> Anyway for single items code that does
>
> if (!has_value(arr, item)) arr += ({ item });
>
> should typically be faster than using |= (up until a few minutes ago that is,
> since I've added an optimization of this case to Pike 7.8).
Test program:
int main()
{
array a = ({});
int i;
float f = gauge {
for (i = 0; i < 10000; i++) {
a |= ({ i });
a |= ({ i });
}
};
werror("elems: %d\ngauge: %O\n", sizeof(a), f);
}
Before:
$ ./test-pike test.pike
elems: 10000
gauge: 57.456952977
After:
$ ./test-pike test.pike
elems: 10000
gauge: 2.815731693
Seems the optimization had effect... :-)
--
Henrik Grubbström <grubba[at]roxen.com>
Roxen Internet Software AB
|