on develop help sign in
Merge pull request #185 from reflex-frp/safe-swap-rows

Only swap rows when the table is large enough

commit1cdea3187bfadda0ffb1ba680a1c0c4260bc4fc6 authorRyan Trinkle <ryan.trinkle@gmail.com> dateTue 21 Nov 2017, 23:46 (9 years ago) parent9fb22293eaaf71
1 file changed+2−1
reflex-dom/benchmarks/krausest.hs+2−1
reflex-dom/benchmarks/krausest.hs+2−1
@@ -120,8 +120,9 @@ filterByIndex :: (Int -> Bool) -> [a] -> [a]
120120filterByIndex p = map snd . filter (\(i, _) -> p i) . zip [0..]
121121
122122swapRows :: (RowIndex, RowIndex) -> (Model, Table) -> (Model, TableDiff)
123−swapRows (a, b) (m, t) = (m, PatchIntMap $ point a b <> point b a)
123+swapRows (a, b) (m, t) = (m, PatchIntMap $ if max a b < length t then swap else empty)
124124 where
125+ swap = point a b <> point b a
125126 point x y = singleton (fst (val x)) $ Just $ snd $ val y
126127 val = (assocs t !!)
127128