[zone] Fix allocate method of ZoneAllocator
This removes two unneeded casts and an unused parameter. Note that according to the specification, {Allocator}s need to provide an {allocate} method receiving the size {n}, and *optionally* they can support {allocate} with a second pointer parameter which they can use in an unspecified manner. Since we do not use the second argument, we should just not provide that method. Drive-by: Remove else-after-return. R=mlippautz@chromium.org Bug: v8:9396 Change-Id: I776c5ae2f6652e20c9f9bfd511c41ce6ad1c1329 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1690831 Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/master@{#62561}
This commit is contained in:
parent
b658d9c749
commit
5aa15fd822
@ -47,11 +47,8 @@ class ZoneAllocator {
|
||||
template <typename U>
|
||||
friend class ZoneAllocator;
|
||||
|
||||
T* allocate(size_t n, const void* hint = nullptr) {
|
||||
return static_cast<T*>(zone_->NewArray<T>(static_cast<int>(n)));
|
||||
}
|
||||
void deallocate(T* p, size_t) { /* noop for Zones */
|
||||
}
|
||||
T* allocate(size_t n) { return zone_->NewArray<T>(n); }
|
||||
void deallocate(T* p, size_t) {} // noop for zones
|
||||
|
||||
size_t max_size() const {
|
||||
return std::numeric_limits<int>::max() / sizeof(T);
|
||||
@ -100,16 +97,15 @@ class RecyclingZoneAllocator : public ZoneAllocator<T> {
|
||||
template <typename U>
|
||||
friend class RecyclingZoneAllocator;
|
||||
|
||||
T* allocate(size_t n, const void* hint = nullptr) {
|
||||
T* allocate(size_t n) {
|
||||
// Only check top block in free list, since this will be equal to or larger
|
||||
// than the other blocks in the free list.
|
||||
if (free_list_ && free_list_->size >= n) {
|
||||
T* return_val = reinterpret_cast<T*>(free_list_);
|
||||
free_list_ = free_list_->next;
|
||||
return return_val;
|
||||
} else {
|
||||
return ZoneAllocator<T>::allocate(n, hint);
|
||||
}
|
||||
return ZoneAllocator<T>::allocate(n);
|
||||
}
|
||||
|
||||
void deallocate(T* p, size_t n) {
|
||||
|
Loading…
Reference in New Issue
Block a user