packages feed

symbolize 1.0.2.2 → 1.0.2.3

raw patch · 3 files changed

+12/−9 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -8,6 +8,10 @@  ## Unreleased +## 1.0.2.3++- Swaps the internal usage of lists in the global symbol table for `NonEmpty` lists, since they will never be empty. (PR [#5](https://github.com/Qqwy/haskell-symbolize/pull/5)). Thank you, @Bodigrim!+ ## 1.0.2.2  - Fixing some typos in the documentation (PR [#3](https://github.com/Qqwy/haskell-symbolize/pull/3)). Thank you, @Bodigrim!
src/Symbolize/SymbolTable.hs view
@@ -21,6 +21,8 @@ import Data.IntMap.Strict (IntMap) import Data.IntMap.Strict qualified as IntMap import Data.List qualified+import Data.List.NonEmpty (NonEmpty(..))+import Data.List.NonEmpty qualified as NonEmpty import Data.Maybe (mapMaybe) import GHC.Exts (ByteArray#, StableName#, Weak#, deRefWeak#, makeStableName#, mkWeak#) import GHC.IO (IO (IO), unsafePerformIO)@@ -45,7 +47,7 @@ data WeakSymbol where   WeakSymbol# :: Weak# ByteArray# -> StableName# ByteArray# -> WeakSymbol -newtype SymbolTable = SymbolTable (IntMap [WeakSymbol])+newtype SymbolTable = SymbolTable (IntMap (NonEmpty WeakSymbol))  -- | The global Symbol Table, containing a mapping between each symbol's textual representation and its deduplicated pointer. --@@ -108,7 +110,7 @@ insert :: Hash -> WeakSymbol -> SymbolTable -> SymbolTable {-# INLINE insert #-} insert key weak (SymbolTable table) =-  let table' = IntMap.insertWith (++) (hashToInt key) (pure weak) table+  let table' = IntMap.alter (Just . maybe (pure weak) (NonEmpty.cons weak)) (hashToInt key) table    in SymbolTable table'  lookup :: ByteArray# -> SipHash.SipKey -> SymbolTable -> Maybe ByteArray@@ -124,10 +126,7 @@   let table' = IntMap.update removeTombstones key table    in SymbolTable table'   where-    removeTombstones weaks =-      case filter isNoTombstone weaks of-        [] -> Nothing-        leftover -> Just leftover+    removeTombstones = NonEmpty.nonEmpty . NonEmpty.filter isNoTombstone     isNoTombstone weak =       case deRefWeakSymbol weak of         Nothing -> False@@ -164,9 +163,9 @@       0# -> (# s1, Nothing #)       _ -> (# s1, Just (ByteArray p) #) -aliveWeaks :: [WeakSymbol] -> [ByteArray]+aliveWeaks :: NonEmpty WeakSymbol -> [ByteArray] {-# INLINE aliveWeaks #-}-aliveWeaks = mapMaybe $ \weak -> deRefWeakSymbol weak+aliveWeaks = mapMaybe deRefWeakSymbol . NonEmpty.toList  -- | Get a handle to the `GlobalSymbolTable` --
symbolize.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           symbolize-version:        1.0.2.2+version:        1.0.2.3 synopsis:       Efficient global Symbol table, with Garbage Collection. description:    Symbols, also known as Atoms or Interned Strings, are a common technique                 to reduce memory usage and improve performance when using many small strings: