Permalink
Browse files

idx: use bitshift for index calculation

  • Loading branch information...
1 parent f8a12de commit cf9d694338dd506409bb6d5e6df7bb65266a98d3 @kfish committed Jun 7, 2011
Showing with 2 additions and 1 deletion.
  1. +2 −1 Git/PackIndex.hs
View
@@ -11,6 +11,7 @@ module Git.PackIndex (
import Control.Applicative ((<$>))
import Control.Monad (msum)
+import Data.Bits (shiftR)
import qualified Data.ByteString as BS
import Data.Word (Word32)
import Foreign.Ptr
@@ -126,7 +127,7 @@ idxFind idx sha = idxFind' 0 (idxSize idx)
LT -> idxFind' lo i
GT -> idxFind' (i+1) hi
where
- i = floor ((fromIntegral (lo + hi)) / 2.0 :: Double)
+ i = shiftR (lo + hi) 1
findInPackIdxs :: BS.ByteString -> IO (Maybe PackObject)
findInPackIdxs sha = do

0 comments on commit cf9d694

Please sign in to comment.