mirror of
https://github.com/composewell/streamly.git
synced 2024-09-11 11:37:22 +03:00
Slice Text instead of copying data
This commit is contained in:
parent
f85802e18f
commit
3c725655a5
@ -192,12 +192,12 @@ instance Serialize Text where
|
|||||||
-- XXX Check the available length in input buffer
|
-- XXX Check the available length in input buffer
|
||||||
if (off1 + lenBytes <= end)
|
if (off1 + lenBytes <= end)
|
||||||
then do
|
then do
|
||||||
newArr <- Unbox.newBytes lenBytes
|
-- newArr <- Unbox.newBytes lenBytes
|
||||||
-- XXX We can perform an unrolled word copy directly
|
-- XXX We can perform an unrolled word copy directly
|
||||||
Unbox.putSliceUnsafe arr off1 newArr 0 lenBytes
|
-- Unbox.putSliceUnsafe arr off1 newArr 0 lenBytes
|
||||||
pure
|
pure
|
||||||
( off1 + lenBytes
|
( off1 + lenBytes
|
||||||
, Text (TArr.Array (unsafeCoerce# (Unbox.getMutableByteArray# newArr))) 0 len16
|
, Text (TArr.Array (unsafeCoerce# (Unbox.getMutableByteArray# arr))) off1 len16
|
||||||
)
|
)
|
||||||
else error $ "deserialize: Text: input buffer underflow: off1 = "
|
else error $ "deserialize: Text: input buffer underflow: off1 = "
|
||||||
++ show off1 ++ " lenBytes = " ++ show lenBytes
|
++ show off1 ++ " lenBytes = " ++ show lenBytes
|
||||||
|
Loading…
Reference in New Issue
Block a user