Skip to content

Commit 8ea534a

Browse files
Rob Lyerlymeta-codesync[bot]
authored andcommitted
Avoid selecting RegionAllocator with invalid arguments in allocate()
Summary: We don't actually use the region allocator if the arguments are invalid, so don't get it unless we actually use it. The compiler *hopefully* already optimizes this away, but just ensure. Reviewed By: AlnisM Differential Revision: D88484601 fbshipit-source-id: 069d8659265e9212a25a9eacf8ba5cad0365a737
1 parent b60ff18 commit 8ea534a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cachelib/navy/block_cache/Allocator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ Allocator::Allocator(RegionManager& regionManager,
5151
std::tuple<RegionDescriptor, uint32_t, RelAddress> Allocator::allocate(
5252
uint32_t size, uint16_t priority, bool canWait, uint64_t keyHash) {
5353
XDCHECK_LT(priority, allocators_.size());
54-
RegionAllocator* ra =
55-
&allocators_[priority][keyHash % allocators_[priority].size()];
5654
if (size == 0 || size > regionManager_.regionSize()) {
5755
return std::make_tuple(RegionDescriptor{OpenStatus::Error}, size,
5856
RelAddress());
5957
}
58+
RegionAllocator* ra =
59+
&allocators_[priority][keyHash % allocators_[priority].size()];
6060
return allocateWith(*ra, size, canWait);
6161
} // namespace cachelib
6262

0 commit comments

Comments
 (0)