Skip to content

Commit

Permalink
Fix unnecessary conditional logic in cache implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
jberryman authored and lexi-lambda committed Dec 20, 2019
1 parent c766881 commit 3f848a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions server/src-lib/Hasura/Cache/Bounded.hs
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,9 @@ getLocal (BoundedCache handles) = do

(i, _) <- myThreadId >>= threadCapability

-- The number of capability could be dynamically changed.
-- So, let's check the upper boundary of the vector
let lim = V.length handles
j | i < lim = i
| otherwise = i `mod` lim
-- The number of capabilities can grow dynamically so make sure we wrap
-- around when indexing.
let j = i `mod` V.length handles

return $ handles V.! j

Expand Down
8 changes: 3 additions & 5 deletions server/src-lib/Hasura/Cache/Unbounded.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ getLocal (UnboundedCache handles) = do

(i, _) <- myThreadId >>= threadCapability

-- The number of capability could be dynamically changed.
-- So, let's check the upper boundary of the vector
let lim = V.length handles
j | i < lim = i
| otherwise = i `mod` lim
-- The number of capabilities can grow dynamically so make sure we wrap
-- around when indexing.
let j = i `mod` V.length handles

return $ handles V.! j

Expand Down

0 comments on commit 3f848a5

Please sign in to comment.