-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix isInfixOf and breakSubString in Word16 #199
Conversation
2b9f111
to
98ba6a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We repeatedly use Data.ByteString.Short.breakSubstring
and Data.ByteString.Short.splitAt
which both copy. See: #199 (comment)
I think we will get more predictable performance characteristics if we convert to a ByteString
first, calculate the offset, and then do a final splitAt
on the original input.
@Bodigrim any more thoughts on this?
I don't think I agree. The point of ShortByteString is that it doesn't use pinned memory and doesn't contribute to memory fragmentation. Even if the ByteString here will be temporary, I find it morally wrong to use it inside the ShortByteString module. |
As discussed in haskell/bytestring#307, I'm not convinced that the algorithm behind Looking at the difficulties with appending/slicing of |
@Bodigrim done |
@@ -441,3 +449,29 @@ errorEmptySBS fun = moduleError fun "empty ShortByteString" | |||
moduleError :: HasCallStack => String -> String -> a | |||
moduleError fun msg = error (moduleErrorMsg fun msg) | |||
{-# NOINLINE moduleError #-} | |||
|
|||
compareByteArraysOff :: BA -- ^ array 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, bytestring doesn't expose this internal and we need it to to be compatible with GHC-8.2.2 and lower.
Fixes #195
@Bodigrim @sol