From d321871c639832210332533cacedde3fe7150d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Tue, 5 Dec 2023 08:55:24 +0100 Subject: [PATCH] Small PbList improvements - Reduce binary size increase caused by cl/586928869 by adding `dart2js:never-inline` pragmas to `add`, `addAll`, `clear`. - Override `isEmpty`, `isNotEmpty` avoid virtual calls to `length`. - Override `get iterator` to use the known iterator type of `_wrappedList`, which is always a `_GrowableList`. cl/587627017 --- protobuf/lib/src/protobuf/pb_list.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/protobuf/lib/src/protobuf/pb_list.dart b/protobuf/lib/src/protobuf/pb_list.dart index 76a73287a..792bfff4e 100644 --- a/protobuf/lib/src/protobuf/pb_list.dart +++ b/protobuf/lib/src/protobuf/pb_list.dart @@ -45,6 +45,7 @@ class PbList extends ListBase { _check = _checkNotNull; @override + @pragma('dart2js:never-inline') void add(E element) { _checkModifiable('add'); _check(element); @@ -52,6 +53,7 @@ class PbList extends ListBase { } @override + @pragma('dart2js:never-inline') void addAll(Iterable iterable) { _checkModifiable('addAll'); iterable.forEach(_check); @@ -74,6 +76,7 @@ class PbList extends ListBase { } @override + @pragma('dart2js:never-inline') void clear() { _checkModifiable('clear'); _wrappedList.clear(); @@ -163,6 +166,16 @@ class PbList extends ListBase { @override int get length => _wrappedList.length; + @override + bool get isEmpty => _wrappedList.isEmpty; + + @override + bool get isNotEmpty => _wrappedList.isNotEmpty; + + @override + @pragma('dart2js:never-inline') + Iterator get iterator => _wrappedList.iterator; + @override set length(int newLength) { _checkModifiable('set length');