More inner loops with more arguments than necessary
- Dominant language
- Haskell
- Stars
- 301
- Forks
- 144
- Avg merge
- 7d 22h
- Merged PRs (30d)
- 1
Description
In #273 and #347 we have optimized several functions by essentially performing static argument transformations by hand. The functions below look like good candidates to attempt similar optimizations.
* [x] `unfoldrN`: (Done in https://github.com/haskell/bytestring/pull/356) I believe we could float out the `p` argument and use `n` as the offset to use with `pokeByteOff`.
https://github.com/haskell/bytestring/blob/c470cf25ea4e71c5f90e32bafc94fd4df4ae15d2/Data/ByteString.hs#L868-L878
* [ ] `partition`: In the `sep` and `rev` loops, `p2` could be computed from `p1`. Alternatively, both memory locations could be tracked via a single offset.
https://github.com/haskell/bytestring/blob/c470cf25ea4e71c5f90e32bafc94fd4df4ae15d2/Data/ByteString.hs#L1477-L1507
* [ ] `hGetLine.findEOL`: It might be worthwhile to float out the `w` and `raw` arguments.
https://github.com/haskell/bytestring/blob/c470cf25ea4e71c5f90e32bafc94fd4df4ae15d2/Data/ByteString.hs#L1846-L1852
* [ ] `Char8.readInt.digits`: The `p` and `b` arguments are always incremented in sync, which indicates that one could be made static and floated out.
https://github.com/haskell/bytestring/blob/c470cf25ea4e71c5f90e32bafc94fd4df4ae15d2/Data/ByteString/Char8.hs#L1056-L1071
* [ ] `Lazy.Char8.readInt.digits`: Same situation as in the strict version
https://github.com/haskell/bytestring/blob/c470cf25ea4e71c5f90e32bafc94fd4df4ae15d2/Data/ByteString/Lazy/Char8.hs#L877-L892
* [ ] `packZipWith.zipWith_`: The `r` argument could be floated out. @Boarders points out that this doesn't always improve performance though: https://github.com/haskell/bytestring/issues/338#issuecomment-762350810. Investigating this might be worthwhile though.
https://github.com/haskell/bytestring/blob/c470cf25ea4e71c5f90e32bafc94fd4df4ae15d2/Data/ByteString.hs#L1667-L1684
* [x] `Short.partition.go.go'`: `bw2 = br - bw1`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.