Closed frasertweedale closed 6 years ago
Interning is not worth it (see https://github.com/purebred-mua/hs-notmuch/issues/14). The work to avoid the copying is probably not worth it. Most headers will be read from the parsed mail, not from libnotmuch, to prevent libnotmuch from opening file descriptors to the mail. Therefore, closing this.
Observe that
message_get_header
will be called with a small number of strings (headers), but will be called many times.Currently, every time
message_get_header
gets invoked it usesB.useAsCString
which allocates (length s + 1) bytes, copies the string (which will be null terminated), and calls the action.It would be better to define a new type for header names that holds a pointer to a null-terminated string that can be used without further ado. Conversion from
B.ByteString
would be O(n) but if a distinguished value is used everywhere, the cost need only be incurred once.A similar approach should be used for tag names, too.