-
Notifications
You must be signed in to change notification settings - Fork 143
Rewrite intercalate in a more direct way #459
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
Conversation
|
A related, but more general question is whether bytestring/Data/ByteString/Internal.hs Lines 663 to 705 in b701111
I suspect that the reasoning to thread |
Data/ByteString.hs
Outdated
| intercalate :: ByteString -> [ByteString] -> ByteString | ||
| intercalate s = concat . List.intersperse s | ||
| intercalate _ [] = mempty | ||
| intercalate (BS f_sep_ptr sep_len) (BS f_h_ptr h_len : t) = |
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.
camelCase please.
Data/ByteString.hs
Outdated
| unsafeCreate total_len $ \dst_ptr0 -> | ||
| unsafeWithForeignPtr f_sep_ptr $ \sep_ptr -> do | ||
| unsafeWithForeignPtr f_h_ptr $ \h_ptr -> | ||
| memcpy dst_ptr0 h_ptr (fromIntegral h_len) |
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.
Please adorn fromIntegral with type applications, explaining what kind of conversion is going on, e. g., fromIntegral @Int @CInt.
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.
Looks like quite a few of those were redundant in that file, I've removed them.
sjakobi
left a comment
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.
Cheers!
* Rewrite intercalate in a more direct way * Remove redundant fromIntegrals * Add intercalate benchmark

One thing that seems suspicious was that there's supposedly efficient
intercalateWithByte, but it only works on two strings.This PR takes the approach from
intercalateWithBytetointercalate. Unfortunately there are not any benchmarks for either function so I don't know where the performance claims ofintercalateWithBytecome from.