[Git][ghc/ghc][master] FastString: SAT bucket_match

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu Dec 1 17:37:18 UTC 2022



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00
FastString: SAT bucket_match

Metric Decrease:
    MultiLayerModulesTH_OneShot

- - - - -


1 changed file:

- compiler/GHC/Data/FastString.hs


Changes:

=====================================
compiler/GHC/Data/FastString.hs
=====================================
@@ -465,8 +465,7 @@ mkFastStringWith mk_fs sbs = do
   FastStringTableSegment lock _ buckets# <- readIORef segmentRef
   let idx# = hashToIndex# buckets# hash#
   bucket <- IO $ readArray# buckets# idx#
-  res <- bucket_match bucket sbs
-  case res of
+  case bucket_match bucket sbs of
     Just found -> return found
     Nothing -> do
       -- The withMVar below is not dupable. It can lead to deadlock if it is
@@ -485,8 +484,7 @@ mkFastStringWith mk_fs sbs = do
       FastStringTableSegment _ counter buckets# <- maybeResizeSegment segmentRef
       let idx# = hashToIndex# buckets# hash#
       bucket <- IO $ readArray# buckets# idx#
-      res <- bucket_match bucket sbs
-      case res of
+      case bucket_match bucket sbs of
         -- The FastString was added by another thread after previous read and
         -- before we acquired the write lock.
         Just found -> return found
@@ -497,11 +495,12 @@ mkFastStringWith mk_fs sbs = do
           _ <- atomicFetchAddFastMut counter 1
           return fs
 
-bucket_match :: [FastString] -> ShortByteString -> IO (Maybe FastString)
-bucket_match [] _ = return Nothing
-bucket_match (fs@(FastString {fs_sbs=fs_sbs}) : ls) sbs
-  | fs_sbs == sbs = return (Just fs)
-  | otherwise     =  bucket_match ls sbs
+bucket_match :: [FastString] -> ShortByteString -> Maybe FastString
+bucket_match fs sbs = go fs
+  where go [] = Nothing
+        go (fs@(FastString {fs_sbs=fs_sbs}) : ls)
+          | fs_sbs == sbs = Just fs
+          | otherwise     = go ls
 
 mkFastStringBytes :: Ptr Word8 -> Int -> FastString
 mkFastStringBytes !ptr !len =



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72cf4c5d74923d267dab2dc260af090609066b04

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72cf4c5d74923d267dab2dc260af090609066b04
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221201/0518fb63/attachment-0001.html>


More information about the ghc-commits mailing list