Skip to content

Perf: Replace .length > 0 with .isNotEmpty on iterables #533

Description

@ZhuchkaTriplesix

Description

There are a couple of instances where collection emptiness is checked via .length > 0 (e.g., in querya_tab_strip.dart and json_rpc_payload_limits.dart).

Why is this a problem?

The .length property on some Dart iterables might require walking the entire collection to count items, whereas .isNotEmpty operates in O(1) time by just checking if the iterator has at least one element.

Proposed Solution

Replace all usages of .length > 0 or .length == 0 with .isNotEmpty and .isEmpty respectively.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions