Small refactoring
authorRoman Leshchinskiy <rl@cse.unsw.edu.au>
Fri, 11 Dec 2009 00:35:56 +0000 (00:35 +0000)
committerRoman Leshchinskiy <rl@cse.unsw.edu.au>
Fri, 11 Dec 2009 00:35:56 +0000 (00:35 +0000)
Data/Vector/Generic/Mutable.hs

index 55a124e..fec2440 100644 (file)
@@ -588,10 +588,7 @@ reverse :: (PrimMonad m, MVector v a) => v (PrimState m) a -> m ()
 reverse !v = reverse_loop 0 (length v - 1)
   where
     reverse_loop i j | i < j = do
-                                 x <- unsafeRead v i
-                                 y <- unsafeRead v j
-                                 unsafeWrite v i y
-                                 unsafeWrite v j x
+                                 unsafeSwap v i j
                                  reverse_loop (i + 1) (j - 1)
     reverse_loop _ _ = return ()