-
Notifications
You must be signed in to change notification settings - Fork 205
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
Make it easy/efficient to create immutable collections via literals #117
Comments
Related: dart-lang/sdk#27755 In Flutter as soon as you pass a collection of objects, typically a |
CC @lrhn, who has written a bit of the code that created fixed-size lists for efficiency. |
The first four examples you link to don't create read-only lists, they create mutable fixed-size ones. Likewise, uses of I really think we need to be clear and explicit when we talk about this. I know of, at least:
Each of these has different use cases, affordances, and constraints. Before we go in the direction of any of these (beyond what we already have), I think we need clearer data about which specific goals users have. |
Updated the title to explicitly call out "immutable". Even in the cases in the SDK where we're creating (strictly speaking) fixed-sized lists, immutable would be more desirable. |
See also #2477 |
See
https://github.com/dart-lang/sdk/blob/031e77eea11a16a5e486a3673549adbd68862c8e/sdk/lib/core/uri.dart#L2233-L2237
Also in the SDK,
2x in this file https://github.com/dart-lang/sdk/blob/031e77eea11a16a5e486a3673549adbd68862c8e/sdk/lib/vmservice/message.dart#L176-L182
4x in this file https://github.com/dart-lang/sdk/blob/031e77eea11a16a5e486a3673549adbd68862c8e/runtime/bin/vmservice/loader.dart#L1107-L1112
This entire file in
pkg:isolate
- https://github.com/dart-lang/isolate/blob/master/lib/src/util.dartIn the Dart sources in Google (some of these duplicate the above)
List.unmodifiable\(\[
- 135 hitsList\<.+\>\.unmodifiable\(\[
- 96 timesMap\<.+,.+>\.unmodifiable\(\{
- 25 timesMap\.unmodifiable\(\{
- 28 timesUnmodifiableSetView
frompkg:collection
is used dozens of times, not as a view over mutable data, but as a immutable set.Benefits:
version
, etcimmutable([1,2,3])
could be created asUint8List
.The text was updated successfully, but these errors were encountered: