Bryan O'Sullivan avatar Bryan O'Sullivan committed e4eca0a

Get rid of a little unnecessary allocation.

Comments (0)

Files changed (1)


       then do
         let scanner (B.PS fp off len) =
               withForeignPtr fp $ \ptr -> do
-                let inner !i !s | i == off+len = return (i-off,s)
+                let inner !i !s | i == off+len = done (i-off) s
                                 | otherwise = do
                                             w <- peekByteOff ptr i
                                             case p s w of
                                               Just s' -> inner (i+1) s'
-                                              Nothing -> return (i-off,s)
-                (i,s') <- inner off s1
-                return (B.PS fp off i, B.PS fp (off+i) (len-i),s')
+                                              Nothing -> done (i-off) s
+                    done !i !s = return (B.PS fp off i, B.PS fp (off+i) (len-i),s)
+                inner off s1
         (h,t,s') <- (unsafePerformIO . scanner) <$> get
         put t
         if B.null t
           then go (h:acc) s'
           else return (h:acc)
       else return acc
-{-# INLINE scan #-}    
+{-# INLINE scan #-}
 -- | Consume input as long as the predicate returns 'True', and return
 -- the consumed input.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.