-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Merge `shortbytestring` package back into `bytestring` wrt #444 * Fix build on ARM Reusing compareByteArrays and avoiding excessive pointer arithmetic. * Speed up reverse by using byteSwap64 tricks * Remove phase control from inlines * Improve performance of elemIndex * Use setByteArray in replicate * Implement intercalate manually * Annotate partial functions with HasCallStack * Fix build on base < 4.12.0.0 * Add uncons/unsnoc * Correct complexities * Exclude reverse optimization path from ARM It seems to cause segfaults on armv7, suggesting there are issues with 'indexWord8ArrayAsWord64#'. All other platforms are fine and tests pass. * Add benchmarks for ShortByteString * Improve inlining * Adjust haddock identifiers * Get rid of writeCharArray# * Haddock fixes * Clean up tests * Use -fexpose-all-unfoldings * Improve reverse * Cleanup 'reverse' * Fix possible GC race with foreign imports For more information, see #471 (comment) * Disable asserts in shortbytestring.c * Remove redundant import * Add documentation about partial functions * Fold ShortByteString prop tests into ByteString * Restore previous INLINEs * Improve naming of bindings * Consolidate error handling functions * Remove trailing whitespace * Fix uncons in documentation * Rename indexWord64Array to indexWord8ArrayAsWord64 * Improve error message * Clean up incorrect documentation * Use div/mod instead of quot/rem * Simplify branching in reverse * Move asserts to Haskell * Prefix C functions * Fix return type of c_elem_index * Fix documentation in unfoldrN * Make unfoldrN more efficient * Fix maintainer field * Fix formatting * Implement takeEnd, dropeEnd and splitAt manually * Fix some haddock identifiers * Fix unfoldrN doc * Add a primops bounds-checking job to CI * Document and clean up createAndTrim * Rename errorEmptyList to errorEmptySBS * Improve documentation for findFromEndUntil * Improve documentation and naming * Optimize out quotRem * Document compareByteArraysOff * Simplify findIndexOrLength and findFromEndUntil * Use c_count for count * Simplify elemIndex * Remove use of 'mempty' * Make sure breakSubstring is inlined into isInfixOf * Simplify stripSuffix and stripPrefix * Fix redundant import warnings * Improve 'take' * Use existing bounnds check in 'drop' * Avoid 'create' when bytestring is empty * Optimize filter * Remove redundant INLINABLE * Use shorter 'createAndTrim' in 'filter' * Simplify 'take' * Simplify 'drop' * Better formatting * Add comment to explain DNDEBUG * Refactor elemIndex * Optimize 'partition' * Optimize hot loop in 'partition' (cherry picked from commit 731caea)
- Loading branch information
Showing
14 changed files
with
1,793 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,10 @@ | |
|
||
-- | | ||
-- Module : Data.ByteString.Short | ||
-- Copyright : (c) Duncan Coutts 2012-2013 | ||
-- Copyright : (c) Duncan Coutts 2012-2013, Julian Ospald 2022 | ||
-- License : BSD-style | ||
-- | ||
-- Maintainer : [email protected] | ||
-- Maintainer : [email protected] | ||
-- Stability : stable | ||
-- Portability : ghc only | ||
-- | ||
|
@@ -67,26 +67,113 @@ module Data.ByteString.Short ( | |
-- small unpinned strings are allocated in the same way as normal heap | ||
-- allocations, rather than in a separate pinned area. | ||
|
||
-- * Conversions | ||
toShort, | ||
fromShort, | ||
-- * Introducing and eliminating 'ShortByteString's | ||
empty, | ||
singleton, | ||
pack, | ||
unpack, | ||
fromShort, | ||
toShort, | ||
|
||
-- * Other operations | ||
empty, null, length, index, indexMaybe, (!?), | ||
-- * Basic interface | ||
snoc, | ||
cons, | ||
append, | ||
last, | ||
tail, | ||
uncons, | ||
head, | ||
init, | ||
unsnoc, | ||
null, | ||
length, | ||
|
||
-- ** Encoding validation | ||
-- * Encoding validation | ||
isValidUtf8, | ||
|
||
-- * Transforming ShortByteStrings | ||
map, | ||
reverse, | ||
intercalate, | ||
|
||
-- * Reducing 'ShortByteString's (folds) | ||
foldl, | ||
foldl', | ||
foldl1, | ||
foldl1', | ||
|
||
foldr, | ||
foldr', | ||
foldr1, | ||
foldr1', | ||
|
||
-- ** Special folds | ||
all, | ||
any, | ||
concat, | ||
|
||
-- ** Generating and unfolding ByteStrings | ||
replicate, | ||
unfoldr, | ||
unfoldrN, | ||
|
||
-- * Substrings | ||
|
||
-- ** Breaking strings | ||
take, | ||
takeEnd, | ||
takeWhileEnd, | ||
takeWhile, | ||
drop, | ||
dropEnd, | ||
dropWhile, | ||
dropWhileEnd, | ||
breakEnd, | ||
break, | ||
span, | ||
spanEnd, | ||
splitAt, | ||
split, | ||
splitWith, | ||
stripSuffix, | ||
stripPrefix, | ||
|
||
-- * Predicates | ||
isInfixOf, | ||
isPrefixOf, | ||
isSuffixOf, | ||
|
||
-- ** Search for arbitrary substrings | ||
breakSubstring, | ||
|
||
-- * Searching ShortByteStrings | ||
|
||
-- ** Searching by equality | ||
elem, | ||
|
||
-- ** Searching with a predicate | ||
find, | ||
filter, | ||
partition, | ||
|
||
-- * Indexing ShortByteStrings | ||
index, | ||
indexMaybe, | ||
(!?), | ||
elemIndex, | ||
elemIndices, | ||
count, | ||
findIndex, | ||
findIndices, | ||
|
||
-- * Low level conversions | ||
-- ** Packing 'Foreign.C.String.CString's and pointers | ||
packCString, | ||
packCStringLen, | ||
|
||
-- ** Using ByteStrings as 'Foreign.C.String.CString's | ||
-- ** Using ShortByteStrings as 'Foreign.C.String.CString's | ||
useAsCString, | ||
useAsCStringLen | ||
useAsCStringLen, | ||
) where | ||
|
||
import Data.ByteString.Short.Internal | ||
|
Oops, something went wrong.