-
Notifications
You must be signed in to change notification settings - Fork 87
Fix incorrect list element count #1944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/// Ignore any non-elements like 'length', 'fixed$length', etc. | ||
static List<Property> _listElementProperties(List<Property> properties) => | ||
properties | ||
.where((p) => p.name != null && int.tryParse(p.name!) != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the lamda can be simplified to (p) => int.tryParse(p.name ?? '') != null
because int.parse('')
returns null
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original is faster though, so prefer to leave it as is for now.
dwds/lib/src/debugging/instance.dart
Outdated
} | ||
/// Return only elements of the list from [properties]. | ||
/// Ignore any non-elements like 'length', 'fixed$length', etc. | ||
static List<Property> _listElementProperties(List<Property> properties) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOC, do you know why this is static
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not need to access any methods or fields. Normally it is much faster to call static methods as they don't require a virtual table but I am not sure it is true for dart. There might be a lint for it as well, I'll try to find it.
List instances received from getObject contain one extra element (comes from JavaScript Array.length property). Make sure we don't count the length field in the returned list instance.