Skip to content
Snippets Groups Projects
This project is mirrored from https://github.com/haskell/bytestring. Pull mirroring updated .
  1. Jan 01, 2025
    • Matthew Craven's avatar
      Use only fixed-width uints in the C itoa functions (#702) · aca65b39
      Matthew Craven authored
      * Use only fixed-width uints in the C itoa functions
      
      The existing logic for decimal encoding of signed ints was a bit
      more complicated than necessary in its handling for negative numbers,
      mostly because of negation overflowing for INT_MIN.
      
      But the absolute value of the smallest signed Int16 does fit into
      an unsigned Word16 without overflowing, allowing some simplification.
      
      Additionally, on hardware with slow integer division instructions,
      fast division-by-known-divisor is typically faster for unsigned types,
      so this change may lead to a slight speed-up on such platforms.
      
      (We could almost certainly produce slightly better code still for
      these platforms by hand, for example by exploiting the fact that
      after the first division the numbers are small enough that a quotient
      by ten can be extracted with a single mulhi and no shift.)
      
      * Remove a dead branch in `integerDec`
      
      If the absolute value of the input is small enough to enter this
      branch, then it fits in an Int and takes the very first branch instead.
      aca65b39
    • Matthew Craven's avatar
      CI: Test with ghc-9.12 (#703) · 4e805797
      Matthew Craven authored
      4e805797
  2. Dec 06, 2024
  3. Oct 28, 2024
  4. Oct 24, 2024
  5. Oct 22, 2024
  6. Oct 15, 2024
  7. Sep 19, 2024
    • Adam Gundry's avatar
      Improve documentation of customStrategy (#692) · c967aca1
      Adam Gundry authored
      * Clarify documentation of 'customStrategy' based on #690
      
      * Remove outdated comments on AllocationStrategy
      
      (These were not visible in the Haddock output anyway.)
      c967aca1
    • Bodigrim's avatar
      CI: add WASM job (#656) · 3f9773d0
      Bodigrim authored
      * Don't build tests with threaded runtime on WASM
      
      * Skip lifting tests on WASM
      
      * Tests: improve reporting of mismatches for IO tests
      
      * Add WASM CI job
      
      * CI: upgrade incantations for emualted tests
      3f9773d0
  8. Sep 18, 2024
    • Adam Gundry's avatar
      Builder: avoid unsound buffer reuse (#690) (#691) · 378d4c36
      Adam Gundry authored
      `toLazyByteString :: Builder -> LazyByteString` had a race condition that could
      generate wrong results if two threads concurrently evaluated the result.  This
      bug was introduced in #581 (5c4d2367) and first
      present in release 0.11.5.0 (as 0c030bb6).
      
      Due to the use of `unsafeDupablePerformIO` for performance, it is critical that
      any IO actions executed when running a `Builder` can be interrupted or executed
      multiple times.  In principle, filling a buffer is safe provided the buffer is
      used only once and the same bytes are written each time. However, `wrapChunk` in
      `buildStepToCIOS` would re-use a buffer in the trimming case after copying its
      contents to produce a new trimmed chunk. This is safe when run in a single
      thread, but if two threads simultaneously execute the code, one of them may
      still be copying the contents while the other starts overwriting the buffer.
      
      This patch fixes `wrapChunk` to unconditionally allocate a new buffer after
      trimming, rather than re-using the old buffer. This will presumably come at a
      slight performance cost for builders inserting many trimmed chunks.
      378d4c36
  9. Jul 20, 2024
  10. Jul 18, 2024
  11. Jun 26, 2024
  12. Jun 20, 2024
  13. Jun 16, 2024
    • Matthew Craven's avatar
      Remove support for ghc < 8.4 (#682) · 0816ae52
      Matthew Craven authored
      Along the way:
      
       * Obseleted CPP and compatibility workarounds were removed
       * Most remaining CPP conditions are moved into
         bytestring-cpp-macros.h and given specific feature names
       * Most imports from ghc-prim are replaced with equivalent
         imports from base
       * Data.ByteString.Builder.RealFloat.Internal is left untouched,
         to avoid unnecessary conflicts
      0816ae52
  14. Jun 05, 2024
  15. Apr 09, 2024
  16. Feb 15, 2024
    • Matthew Craven's avatar
      Prepare changelog for 0.12.1.0 (#658) · 314e2574
      Matthew Craven authored
      * WIP: Prepare changelog for 0.12.1.0
      
      * fiddle with CI
      
      * Revert "fiddle with CI"
      
      This reverts commit 3e220052bb1f98ea574f7a362b98bf96fdc01f7e.
      
      * More changelog updates
      
      * Mention `pure-haskell` flag in Changelog.md
      
      * Add hidden entry for #660
      314e2574
    • Matthew Craven's avatar
      Remove remaining uses of FFI under -fpure-haskell (#660) · 305604c4
      Matthew Craven authored
      All of these were standard C functions that GHC's JS backend
      actually somewhat supports; their shims can be found in the
      compiler source at "rts/js/mem.js".  But it seems simpler to
      just get rid of all FFI uses with -fpure-haskell rather than
      try to keep track of which functions GHC supports.
      
      The pure Haskell implementation of memcmp runs about 6-7x as fast
      as the simple one-byte-at-a-time implementation for long equal
      buffers, which makes it...  about the same speed as the
      pre-existing shim, even though the latter is also a one-byte-
      at-a-time implementation!
      
      Apparently GHC's JS backend is not yet able to produce efficient
      code for tight loops like these yet; the biggest problem is that
      it does not perform any loopification so each iteration must go
      through a generic-call indirection.
      
      Unfortunately that means that this patch probably makes 'strlen'
      and 'memchr' much slower with the JS backend.
      305604c4
    • Matthew Craven's avatar
    • Matthew Craven's avatar
      Use `BS.unsafeCreateFp` in `fromShort` (#662) · 70fa96b6
      Matthew Craven authored
      This ensures that the result of `fromShort` is properly
      protected by a call to `mkDeferredByteString`.
      70fa96b6
    • Matthew Craven's avatar
      Fix known type mismatch in sbs_elem_index (#661) · 418515e9
      Matthew Craven authored
      See #653.  A complete audit has not been done,
      but let's just fix the known bug anyway.
      418515e9
  17. Feb 07, 2024
    • Sylvain Henry's avatar
      Add pure Haskell implementation (#631) · d497f398
      Sylvain Henry authored
      
      bytestring used to rely on C functions. This patch adds equivalent
      functions implemented in Haskell. The main purpose is for the JavaScript
      backend to fully support bytestring.
      
      Pure Haskell implementation can be enabled explicitly with a cabal flag.
      It's automatically enabled for the JavaScript platform.
      
      Thanks to Matthew Craven for the thorough review and the many
      suggestions.
      
      Co-authored-by: Matthew Craven's avatarMatthew Craven <clyring@gmail.com>
      d497f398
  18. Feb 04, 2024
    • Matthew Craven's avatar
      Data.ByteString.Lazy.dropEnd: Use two-pointers technique (#629) · 2bbc97ea
      Matthew Craven authored
      * Data.ByteString.Lazy.dropEnd: Use two-pointers technique
      
      This can be seen as using the input itself as an implicit
      queue; we formerly copied its chunks into an explicit queue.
      
      By writing the key logic as a polymorphic `splitAtEndFold`,
      it was easy to re-use it for `takeEnd`; the latter function
      should now operate in constant stack space and can release
      initial chunks of a very long input string sooner.
      
      * Fix a very silly bug, and strengthen tests
      
      ...so that a plain 'cabal test' finds the bug almost every try
      instead of finding it only every few dozen tries
      
      * Actually work around the poison instance
      
      (Some re-compilation check somewhere set a trap for me.)
      
      This also replaces fromIntegral with intToIndexTy in a few places.
      
      * Rewrite the poison instance using TypeError
      
      * Rename "bsL" -> "toSplit" and "bsR" -> "toScan"
      
      * Add basic benchmarks for lazy takeEnd/splitEnd
      
      According to these benchmarks, the new implementation for takeEnd
      is somewhat faster and the new implementation for dropEnd is roughly
      3.5x to 4x as quick as its predecessor.
      2bbc97ea
  19. Feb 03, 2024
  20. Feb 02, 2024
  21. Jan 31, 2024
  22. Jan 30, 2024
  23. Nov 26, 2023
  24. Nov 16, 2023
    • Matthew Craven's avatar
      Attempt to fix CI again (#626) · bf5f5da4
      Matthew Craven authored
      The windows jobs were subtly broken by #613, which caused
      the build products to live in bytestring-*/dist-newstyle
      instead of dist-newstyle.  This didn't appear to break
      immediately because we restored cached stuff in dist-newstyle
      including stale executables.  It wasn't until a week of
      inactivity caused our cache to expire that the breakage
      became appropriately obvious.
      
      I don't really understand what went wrong with the centos job;
      I just borrowed the workaround from haskell/text#541.
      bf5f5da4
  25. Nov 07, 2023
    • Bodigrim's avatar
      Implement instance Data (#614) · 1b9e6ec9
      Bodigrim authored
      
      * Add functionality for toConstr
      
      * Other instances fixed
      
      * Move test
      
      * test passes
      
      * Add gshow tests
      
      * Typo
      
      * Add explicit string test
      
      * instance Data: implement gunfold and dataTypeOf
      
      * instance Data: fix tests
      
      * Fix emulated builds
      
      * Restore derived instance Data ShortByteString
      
      * Add instance Generic ShortByteString
      
      * Review suggestions
      
      ---------
      
      Co-authored-by: default avatarColton Clemmer <coltonclemmerdev@gmail.com>
      1b9e6ec9
    • Matthew Craven's avatar
      Remove NOINLINE on lowerTable (#624) · c8b844f8
      Matthew Craven authored
      This seems to exist for no reason, and prevents case-of-known-
      constructor from eliminating an indirection in downstream modules.
      c8b844f8
  26. Nov 05, 2023
Loading