I have now measured the proposed optimisation of stealing a string
pointer with talloc_steal and finalising it with talloc_free,
instead of allocating and copying a new ByteString.
The good news is that the suggested optimisation works.
The bad news is that it isn't really an optimisation unless the
strings are quite a bit longer than the overhead of a ForeignPtr.
In our use case (tags, header values, filenames) this is not the
case. I have profiled the approach with hs-notmuch-tags-count and
found:
I have now measured the proposed optimisation of stealing a string pointer with talloc_steal and finalising it with talloc_free, instead of allocating and copying a new ByteString.
The good news is that the suggested optimisation works.
The bad news is that it isn't really an optimisation unless the strings are quite a bit longer than the overhead of a ForeignPtr. In our use case (tags, header values, filenames) this is not the case. I have profiled the approach with hs-notmuch-tags-count and found:
Overall it seems not to be worth it.