Post

Replies

Boosts

Views

Activity

What is the difference between Data and [UInt8]?
When designing APIs that deal with byte-level data, is there a good reason to use Data as a buffer instead of [UInt8]? From what I understand, Arrays of trivial types like UInt8 are always stored contiguously in memory. But I also know even SwiftNIO uses its own ByteBuffer type instead of [UInt8]. What do these buffer types do differently, and am I giving up on valuable performance or safety by simply using [UInt8]?
3
0
2.9k
Apr ’22
What is the difference between Data and [UInt8]?
When designing APIs that deal with byte-level data, is there a good reason to use Data as a buffer instead of [UInt8]? From what I understand, Arrays of trivial types like UInt8 are always stored contiguously in memory. But I also know even SwiftNIO uses its own ByteBuffer type instead of [UInt8]. What do these buffer types do differently, and am I giving up on valuable performance or safety by simply using [UInt8]?
Replies
3
Boosts
0
Views
2.9k
Activity
Apr ’22