Skip to content

Commit

Permalink
Remove stringsearch dependency (#2765)
Browse files Browse the repository at this point in the history
Fixes #2726
  • Loading branch information
martijnbastiaan authored Jul 26, 2024
1 parent 0065f04 commit 75dbbeb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog/2024-07-21T16_46_47+02_00_remove_stringsearch
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FIXED: Removed `stringsearch` dependency from `v16-upgrade-primitives`. See [#2726](https://github.com/clash-lang/clash-compiler/issues/2726)
2 changes: 1 addition & 1 deletion clash-lib/clash-lib.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,9 @@ executable v16-upgrade-primitives
yaml,
bytestring,
clash-lib,
text,
containers,
directory,
stringsearch,
Glob
GHC-Options: -Wall -Wcompat
default-language: Haskell2010
Expand Down
8 changes: 5 additions & 3 deletions clash-lib/tools/v16-upgrade-primitives.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ module Main where

#if MIN_VERSION_aeson(2,0,0)
import qualified Data.Aeson.KeyMap as Aeson
import Data.ByteString.Lazy.Search (replace)
import Data.String (IsString)
import qualified Data.Text.Lazy as LazyText
import qualified Data.Text.Lazy.Encoding as LazyText
#endif

import qualified Data.Aeson.Extra as AesonExtra
Expand Down Expand Up @@ -89,9 +90,10 @@ customSortOutput x = case x of
Just val -> Aeson.insert kNew val (Aeson.delete kOld obj)

removeTempKey :: ByteString -> ByteString
removeTempKey inp = foldl go inp keySortingRenames
removeTempKey inp =
LazyText.encodeUtf8 (foldl go (LazyText.decodeUtf8 inp) keySortingRenames)
where
go bs (orig,temp) = replace (ByteString.toStrict temp) orig bs
go txt (orig,temp) = LazyText.replace temp orig txt
#else
-- < aeson-2.0 stores keys in HashMaps, whose order we can't possibly predict.
removeTempKey :: ByteString -> ByteString
Expand Down

0 comments on commit 75dbbeb

Please # to comment.