ZHaskell / stdio

Haskell Standard Input and Output
104 stars 5 forks source link

ByteString conversions #27

Closed jac3km4 closed 9 months ago

jac3km4 commented 5 years ago

Added the ByteString conversions I've slightly changed bytesFromByteString, I think it should be better now Also, I've added it to Std.Foreign.PrimArray, because putting it in Std.Vector.Base would cause circular module dependencies, since Std.Foreign.PrimArray uses the vector modules.

winterland1989 commented 5 years ago

It's OK to add these to Std.Foreign.PrimArray, but I still want to avoid copying in those functions if possible. You can do it by directly match on PrimVector or ByteString's contructor, get the ByteArray# (or MutableByteArray# if possible):

I know it sounds complicated, but It's probably better than doing copy and allocation everytime, since: