Reduce the number of dynamic calls.
BUG=
R=skybrian@google.com
Review URL: https://codereview.chromium.org//2012073002 .
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0b1247d..7c4dcc3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.5.1+3
+
+* Performance: eliminate some dynamic calls.
+
## 0.5.1+2
* Bugfix: remove dependency on `pkg/crypto` for real.
diff --git a/lib/src/protobuf/generated_message.dart b/lib/src/protobuf/generated_message.dart
index 8e07612..ef513c0 100644
--- a/lib/src/protobuf/generated_message.dart
+++ b/lib/src/protobuf/generated_message.dart
@@ -67,10 +67,8 @@
// TODO(antonm): move to getters.
int getTagNumber(String fieldName) => info_.tagNumber(fieldName);
- bool operator ==(other) {
- if (other is! GeneratedMessage) return false;
- return _fieldSet._equals(other._fieldSet);
- }
+ bool operator ==(other) =>
+ other is GeneratedMessage ? _fieldSet._equals(other._fieldSet) : false;
/// Calculates a hash code based on the contents of the protobuf.
///
diff --git a/lib/src/protobuf/utils.dart b/lib/src/protobuf/utils.dart
index 6e6482b..a9993e3 100644
--- a/lib/src/protobuf/utils.dart
+++ b/lib/src/protobuf/utils.dart
@@ -18,10 +18,11 @@
}
bool _areListsEqual(List lhs, List rhs) {
- range(i) => new Iterable.generate(i, (i) => i);
-
if (lhs.length != rhs.length) return false;
- return range(lhs.length).every((i) => _deepEquals(lhs[i], rhs[i]));
+ for (var i = 0; i < lhs.length; i++) {
+ if (!_deepEquals(lhs[i], rhs[i])) return false;
+ }
+ return true;
}
bool _areMapsEqual(Map lhs, Map rhs) {
diff --git a/pubspec.yaml b/pubspec.yaml
index 688be86..2e205fc 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: protobuf
-version: 0.5.1+2
+version: 0.5.1+3
author: Dart Team <misc@dartlang.org>
description: Runtime library for protobuf support.
homepage: https://github.com/dart-lang/dart-protobuf