-
Notifications
You must be signed in to change notification settings - Fork 6k
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!); | ||
|
Member
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
Contributor
Author
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?
Member
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
Contributor
Author
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.
Contributor
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
bytesgetter (which returns a non-nullableByteData) that is already available inReadResultandReadEtcResultThere 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.