Avoid slow linear growth of Queues used in the JIT (534168, r=dvander).

This commit is contained in:
Andreas Gal 2009-12-11 16:12:48 -08:00
parent e3cb70404e
commit 7a543ac5b0

View File

@ -66,10 +66,11 @@ class Queue {
public:
void ensure(unsigned size) {
if (_max > size)
return;
if (!_max)
_max = 16;
while (_max < size)
_max <<= 1;
_max = 8;
_max = JS_MAX(_max * 2, size);
if (alloc) {
T* tmp = new (*alloc) T[_max];
memcpy(tmp, _data, _len * sizeof(T));