-
Notifications
You must be signed in to change notification settings - Fork 1.7k
API to create deeply immutable typed data, from one or multiple chunks. #50068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This API sounds unrelated to being unmodifiable. We should have a modifiable Building a buffer from chunks would apply to both kinds of buffers. So, we can have both Or even (The |
LGTM. @lrhn would this be something you'd like to do? (Side note: Maybe
Something for dart 3.0? (could make |
Design the API, sure. Can you elaborate a little more on how the native unmodifiable type data works? We can update the external factory Uint8List.fromList(List<int> bytes, {bool unmodifiable = false}); The immutable list will have the same API and static type as the mutable list. With that as a way to directly create an unmodifiable typed-data lis, I'd assume the The second part, concatenating existing bytes, could be a separate constructor: external factory Uint8List.fromLists(Iterable<List<int>> bytes, {bool unmodifiable = false}); Those two constructor changes should be the only needed API for this to work. We can consider adding a WDYT? |
Uh oh!
There was an error while loading. Please reload this page.
The VM has support for deeply immutable typed data. Those can be shared by-pointer across isolates. Though right now one can only create them using an embedder API.
Using
UnmodifiableUint8ListView(bytes)
is not deeply immutable, becausebytes
may be mutable and someone may write to them.So I propose to make an API that can make an
UnmodifiableUint8ListView
from anyUint8List
and it may make a copy of it if the underlying bytes are mutable.Since data is often available as chunks (e.g. loading from network results in
List<Uint8List>
), the API should support makingUnmodifiableUint8ListView
from such a set of chunks.A possible API would be
/cc @lrhn opinions about the API?
The text was updated successfully, but these errors were encountered: