GLib.Bytes.slice doesn't utilize GLib.Bytes for memory efficiency
GLib.Bytes.slice is a method added to GLib.Bytes, a class defined by core GLib for efficiently referencing slices of memory, by Vala's VAPIs. As such it's reasonable to assume that GLib.Bytes.slice uses GLib.Bytes (specifically GLib.Bytes.from_bytes) in order to maintain this memory efficiency, but no. As it currently is it's implemented in terms of an array slice which triggers the memory to be allocated and copied on return.
In my case this caused some code I wrote to bottleneck on GLib.Bytes.slice and become visibly slow. But I've fixed that now by adding another wrapper around GLib.Bytes which has also improved my code in other ways. So while I no longer need this fixed, I will recommend you fix it for others.
Edited by Ghost User