-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Const typed data (Int8List, et al.) #6378
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
Siva, Running in production mode, that code is: const var int8 = const [10, 100]; Looks like you're asking for a new literal for scalar lists? Added Triaged label. |
It could be handled by a const constructor on Uint8List that takes a const List<int> as argument. It will require compiler magic to actually become a real Uint8List, and I don't see it happening any time soon. |
Removed Type-Defect label. |
Set owner to @lrhn. |
Creating a const typed-data list is not a library issue - it needs language support. For one thing, all type-data lists are currently mutable. Maybe if we had an immutable ByteBuffer, it would make more sense. Removed the owner. |
Not unreasonable, but not planned either. The set of classes and operations that could be usefully made const is potentially unbounded and it's hard to decide what makes the cut and what doesn't. At least for now, we don't have any intention of including typed_data's types in it. |
any update for const typed data, is it still unplanned for the time being? |
There are still no current plans. |
So |
@munificent @lrhn any recommendation for performance junkies? |
For performance, I'd definitely go with: final b = Uint8List(3)..[0] = 4..[1] = 3..[2] = 5; If I could trust the compiler to optimize Creating and populating a Also consider: final b = "\x04\x03\x05".codeUnits; 👿 |
e.g:
const Int8Array int8 = const [10, 100];
does not work, instead we need to write code as follows:
Int8Array initInt8Array() {
var list = new Int8Array(2);
list[0] = 10;
list[1] = 100;
return list;
}
Int8Array int8 = initInt8Array();
We should try and make it possible to initialize constant scalar lists
similar to how we initialize all lists.
The text was updated successfully, but these errors were encountered: