Skip to content
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

Manual roll of Dart with fixups to zircon system.dart #44185

Merged
merged 2 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ vars = {
# Dart is: https://github.com/dart-lang/sdk/blob/main/DEPS
# You can use //tools/dart/create_updated_flutter_deps.py to produce
# updated revision list of existing dependencies.
'dart_revision': '4fd35600b477d18b024fa1b31f42204fab2fccd0',
'dart_revision': '0e02245635eaf23fa5d6a62b059a90aae34fffe0',

# WARNING: DO NOT EDIT MANUALLY
# The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py
Expand Down
2 changes: 1 addition & 1 deletion ci/licenses_golden/licenses_dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Signature: eca8a55f4f8e1225df85bb269749e68c
Signature: a4dee66e7471aa133d109697527a267d

====================================================================================================
LIBRARY: dart
Expand Down
6 changes: 4 additions & 2 deletions shell/platform/fuchsia/dart-pkg/zircon/lib/src/system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class ReadResult extends _Result {
/// Returns the bytes as a Uint8List. If status != OK this will throw
/// an exception.
Uint8List bytesAsUint8List() {
return _bytes!.buffer.asUint8List(_bytes!.offsetInBytes, _numBytes!);
final lbytes = _bytes!;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the bytes getter (which returns a non-nullable ByteData) that is already available in ReadResult and ReadEtcResult

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return lbytes.buffer.asUint8List(lbytes.offsetInBytes, _numBytes!);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove lbytes and replace it with bytes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't that be a little less efficient with two getter calls involving null checks?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either is fine - not sure if it matters for performance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added @stereotype441 for his take on which form would be better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a lot to add about which form would be better. @a-siva is right that two getter calls involving null checks might in principle be slightly worse in performance. Then again, it's possible that due to inlining, the two null checks will be recognized by an optimization pass as redundant, in which case it might not matter at all. It's also possible that this is simply not a hot enough code path to have a noticeable effect.

So lgtm either way.

}

/// Returns the bytes as a String. If status != OK this will throw
Expand Down Expand Up @@ -129,7 +130,8 @@ class ReadEtcResult extends _Result {
/// Returns the bytes as a Uint8List. If status != OK this will throw
/// an exception.
Uint8List bytesAsUint8List() {
return _bytes!.buffer.asUint8List(_bytes!.offsetInBytes, _numBytes!);
final lbytes = _bytes!;
return lbytes.buffer.asUint8List(lbytes.offsetInBytes, _numBytes!);
}

/// Returns the bytes as a String. If status != OK this will throw
Expand Down