Bug 834108 - avoid O(n^2) chunk-searching in LifoAlloc::ensureUnusedApproximate (r=dvander)

--HG--
extra : rebase_source : d3cb159978d10e6f74984d8556784081b2c940b9
This commit is contained in:
Luke Wagner 2013-01-24 14:36:17 -08:00
Родитель 95e008be66
Коммит ab9eaeb05d
2 изменённых файлов: 6 добавлений и 12 удалений

Просмотреть файл

@ -140,12 +140,3 @@ LifoAlloc::transferUnusedFrom(LifoAlloc *other)
other->last = other->latest;
}
}
bool
LifoAlloc::ensureUnusedApproximateSlow(size_t n)
{
// This relies on the behavior that releasing a chunk does not immediately free it.
LifoAllocScope scope(this);
return !!getOrCreateChunk(n);
}

Просмотреть файл

@ -182,8 +182,6 @@ class LifoAlloc
last = end;
}
bool ensureUnusedApproximateSlow(size_t n);
public:
explicit LifoAlloc(size_t defaultChunkSize) { reset(defaultChunkSize); }
@ -246,7 +244,12 @@ class LifoAlloc
return true;
chunk = chunk->next();
}
return ensureUnusedApproximateSlow(n);
BumpChunk *latestBefore = latest;
if (!getOrCreateChunk(n))
return false;
if (latestBefore)
latest = latestBefore;
return true;
}
template <typename T>