-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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!; | ||
return lbytes.buffer.asUint8List(lbytes.offsetInBytes, _numBytes!); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either is fine - not sure if it matters for performance There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added @stereotype441 for his take on which form would be better. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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 | ||
|
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.
Use the
bytes
getter (which returns a non-nullableByteData
) that is already available inReadResult
andReadEtcResult
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.
Done.