Re: ByteArray / Uint8Array





On Tue, Oct 31, 2017 at 10:13 PM, <philip chimento gmail com> wrote:
Hi list,

I have some code in progress to revamp GJS's ByteArray to use a standard _javascript_ Uint8Array (part of modern _javascript_'s typed array family) instead of the custom GJS object. Read more about it here: https://gitlab.gnome.org/GNOME/gjs/issues/5

Does anyone have any thoughts on ByteArray or see any problems with the proposed course of action?

One of the reasons ByteArray exists is that it wraps GByteArray and GBytes from glib.
In particular for GBytes, it means that, as long as you don't modify the underlying store, you can pass around binary data between libraries with no copies.
I don't know if JS UInt8Arrays allow that, and I worry they would not - at the very least, it would be hard to do the copy-on-write behavior ByteArray has.

At the same time, as you point out in the bug, GLib.Bytes exists and would not go away.
It could be extended to do field access so that JS can read the actual data, removing the need to wrap it in a zero-copy ByteArray.


Cheers,

Giovanni


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]