mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 834108 - avoid O(n^2) chunk-searching in LifoAlloc::ensureUnusedApproximate (r=dvander)
--HG-- extra : rebase_source : d3cb159978d10e6f74984d8556784081b2c940b9
This commit is contained in:
parent
374464c2bb
commit
bebb8515b0
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user