Skip to content

Commit

Permalink
make nextPermutation faster
Browse files Browse the repository at this point in the history
  • Loading branch information
toyboot4e committed Jul 20, 2024
1 parent 5d4226e commit b39874a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions vector/src/Data/Vector/Generic/Mutable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1243,8 +1243,7 @@ nextPermutation v
| i == dim = return (k,l)
| otherwise = do
cur <- unsafeRead v i
-- TODO: make tuple unboxed
let (kval',k') = if prev < cur then (prev,i-1) else (kval,k)
let (!kval',!k') = if prev < cur then (prev,i-1) else (kval,k)
l' = if kval' < cur then i else l
loop kval' k' l' cur (i+1)
dim = length v
Expand Down

0 comments on commit b39874a

Please sign in to comment.