Skip to content

Reduce code size, use base libraries instead of NIH, use bytestring - #2

Merged
jappeace merged 1 commit into
masterfrom
reduce-code-size
Mar 2, 2026
Merged

jappeace merged 1 commit into
masterfrom
reduce-code-size

Conversation

@jappeace

@jappeace jappeace commented Mar 2, 2026

Copy link
Copy Markdown
Owner
  • Data.ByteArray.Encoding: replaced custom Base16/Base32/Base64 encode/decode with base16, base32, and base64 library calls. Input is converted to ByteString via B.convert, the library function is applied, and the result is converted back. Base64OpenBSD retains its custom implementation (no library equivalent exists).
  • Data.ByteArray.Bytes: replaced low-level GHC.Prim MutableByteArray# implementation with newtype Bytes = Bytes ByteString. Both use GHC's pinned allocator; ByteString already implements ByteArrayAccess / ByteArray.
  • Data.Memory.Hash.FNV: replaced readWord8OffAddr# (GHC.Prim) with Foreign.Storable.peekByteOff — portable and equivalent.
  • Data.Memory.Internal.CompatPrim64: deleted (was entirely unreferenced).
  • New dependencies: base16 >=1.0 && <2, base32 >=0.4 && <1, base64 >=1.0 && <2, text >=1.0 && <3.
  • Net reduction: ~350 lines removed.

+ `Data.ByteArray.Encoding`: replaced custom Base16/Base32/Base64 encode/decode
  with `base16`, `base32`, and `base64` library calls. Input is converted to
  `ByteString` via `B.convert`, the library function is applied, and the result
  is converted back. `Base64OpenBSD` retains its custom implementation (no
  library equivalent exists).
+ `Data.ByteArray.Bytes`: replaced low-level `GHC.Prim` `MutableByteArray#`
  implementation with `newtype Bytes = Bytes ByteString`. Both use GHC's pinned
  allocator; `ByteString` already implements `ByteArrayAccess` / `ByteArray`.
+ `Data.Memory.Hash.FNV`: replaced `readWord8OffAddr#` (GHC.Prim) with
  `Foreign.Storable.peekByteOff` — portable and equivalent.
+ `Data.Memory.Internal.CompatPrim64`: deleted (was entirely unreferenced).
+ New dependencies: `base16 >=1.0 && <2`, `base32 >=0.4 && <1`,
  `base64 >=1.0 && <2`, `text >=1.0 && <3`.
+ Net reduction: ~350 lines removed.
@jappeace
jappeace merged commit 55ae685 into master Mar 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant