Skip to content

Commit

Permalink
Minor performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Dec 18, 2023
1 parent 6aae604 commit f22bcc8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
6 changes: 1 addition & 5 deletions lib/services/nt_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,7 @@ class NTConnection {
}

Object? getLastAnnouncedValue(String topic) {
if (_ntClient.lastAnnouncedValues.containsKey(topic)) {
return _ntClient.lastAnnouncedValues[topic];
}

return null;
return _ntClient.lastAnnouncedValues[topic];
}

void unpublishTopic(NT4Topic topic) {
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/nt_widgets/multi-topic/field_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ class FieldWidget extends NTWidget {

List<Object> currentData = getCurrentData();

if (!(const DeepCollectionEquality().equals(previousData, currentData))) {
if (!NTWidget.listEquals(previousData, currentData)) {
yield Object();
previousData = currentData;
} else if (!rendered) {
Expand Down
4 changes: 3 additions & 1 deletion lib/widgets/nt_widgets/nt_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ abstract class NTWidget extends StatelessWidget {
});
}

static final Function listEquals = const DeepCollectionEquality().equals;

@protected
List<Object> getCurrentData() {
return [];
Expand All @@ -180,7 +182,7 @@ abstract class NTWidget extends StatelessWidget {
while (true) {
List<Object> currentData = getCurrentData();

if (!(const DeepCollectionEquality().equals(previousData, currentData))) {
if (!listEquals(previousData, currentData)) {
yield Object();
previousData = currentData;
}
Expand Down

0 comments on commit f22bcc8

Please sign in to comment.