Add support for "foo"## literals to MagicHash
I'm working on a high-performance library for building up buffers of data. Appending ByteStrings works pretty well, but, for bytestring literals, it's faster to avoid the CAF (and it's associated tag check + indirect jump) entirely and append a zero-terminate MagicHash string literal via Addr#.
Then I discovered that it's 30% faster if you can avoid the strlen with an explicit length. See this benchmark: https://github.com/chadaustin/buffer-builder/blob/ac662962d6d3c21f206ab8e8121323b9f18677fa/bench/Bench.hs#L42
That API is not very pleasant, of course. :)
Thus, here is a feature request:
It would be great if "foo"## produced (# Int#, Addr# #), where the Int# is the length of the buffer in bytes.
The compiler could enforce that the literal only contains 8-bit values.
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.4 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |