-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Change Intent
Make Utf8Codec.encode() return a Uint8List instead of a List<int>.
Justification
This change will to allow compilers to better optimize code which is accessing the bytes. It also allows being explicit about the guarantees we make: We already guarantee to return a Uint8List but it's not visible in the return type. Some users then do explicit downcasts via utf8.encode(...) as Uint8List, others pass around List<int> which can result in inefficient code.
Impact
The impact will be more precision in static types and smaller code size / higher performance is some cases. It may break existing code if such code is relying on type inference to infer List<int> and would fail if it would now infer Uint8List.
Mitigation
Explicitly pass List<int> as type arguments in places where the automatically inferred Uint8List type is incorrect.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status