Skip to content
Browse files

(`shiftR` 1) instead of (`quot` 2)

  • Loading branch information...
1 parent 840f0c4 commit f4d40e884388184aa6c8d2954e4f1a6dd739bf70 @shachaf shachaf committed
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/Control/Lens/Internal/ByteString.hs
View
5 src/Control/Lens/Internal/ByteString.hs
@@ -30,6 +30,7 @@ import qualified Data.ByteString.Lazy as BL
import qualified Data.ByteString.Lazy.Internal as BLI
import qualified Data.ByteString.Lazy.Char8 as BL8
import qualified Data.ByteString.Internal as BI
+import Data.Bits
import Data.Char
import Data.Int (Int64)
import Data.Word (Word8)
@@ -92,7 +93,7 @@ traversedStrictTree i0 pafb (BI.PS fp off len) = rebuild len <$> go i0 (i0 + len
p = unsafeForeignPtrToPtr fp `plusPtr` (off - i0)
rebuild n f = unsafeCreate n $ \q -> f (q `plusPtr` (off - i0))
go !i !j
- | i + grain < j, k <- i + quot (j - i) 2 = (\l r q -> l q >> r q) <$> go i k <*> go k j
+ | i + grain < j, k <- i + shiftR (j - i) 1 = (\l r q -> l q >> r q) <$> go i k <*> go k j
| otherwise = run i j
run !i !j
| i == j = pure (\_ -> return ())
@@ -111,7 +112,7 @@ traversedStrictTree8 i0 pafb (BI.PS fp off len) = rebuild len <$> go i0 (i0 + le
p = unsafeForeignPtrToPtr fp `plusPtr` (off - i0)
rebuild n f = unsafeCreate n $ \q -> f (q `plusPtr` (off - i0))
go !i !j
- | i + grain < j, k <- i + quot (j - i) 2 = (\l r q -> l q >> r q) <$> go i k <*> go k j
+ | i + grain < j, k <- i + shiftR (j - i) 1 = (\l r q -> l q >> r q) <$> go i k <*> go k j
| otherwise = run i j
run !i !j
| i == j = pure (\_ -> return ())

0 comments on commit f4d40e8

Please sign in to comment.
Something went wrong with that request. Please try again.