Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1429)

Unified Diff: mojo/public/dart/mojo/lib/src/codec.dart

Issue 1410053002: Dart: Uses a pre-allocated buffer for message pipe query and read. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/dart/embedder/mojo_natives.cc ('k') | mojo/public/dart/mojo/lib/src/message.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/dart/mojo/lib/src/codec.dart
diff --git a/mojo/public/dart/mojo/lib/src/codec.dart b/mojo/public/dart/mojo/lib/src/codec.dart
index 0e8af2e0d5178169e56a487aff56850c4d1d9223..c929fe09447f2faa3675d18091dcfba89b6fcc07 100644
--- a/mojo/public/dart/mojo/lib/src/codec.dart
+++ b/mojo/public/dart/mojo/lib/src/codec.dart
@@ -105,7 +105,8 @@ class Encoder {
return result;
}
- Message get message => new Message(_buffer.trimmed, _buffer.handles);
+ Message get message => new Message(
+ _buffer.trimmed, _buffer.handles, _buffer.extent, _buffer.handles.length);
void encodeStructDataHeader(StructDataHeader dataHeader) {
_buffer.claimMemory(align(dataHeader.size));
@@ -572,8 +573,7 @@ class Decoder {
Decoder(this._message, [this._base = 0, this._validator = null]) {
if (_validator == null) {
- _validator =
- new _Validator(_message.buffer.lengthInBytes, _message.numHandles);
+ _validator = new _Validator(_message.dataLength, _message.handlesLength);
}
}
@@ -585,11 +585,13 @@ class Decoder {
ByteData get _buffer => _message.buffer;
List<core.MojoHandle> get _handles => _message.handles;
- List<core.MojoHandle> get excessHandles => (_message.handles == null)
- ? null
- : (new List.from(_message.handles
- .getRange(_validator._minNextClaimedHandle, _message.handles.length))
- ..addAll(_validator._skippedIndices.map((i) => _message.handles[i])));
+ List<core.MojoHandle> get excessHandles {
+ if (_message.handlesLength == 0) return null;
+ var leftAtEnd = _message.handles
+ .getRange(_validator._minNextClaimedHandle, _message.handlesLength);
+ var skipped = _validator._skippedIndices.map((i) => _message.handles[i]);
+ return new List.from(leftAtEnd)..addAll(skipped);
+ }
int decodeInt8(int offset) => _buffer.getInt8(_base + offset);
int decodeUint8(int offset) => _buffer.getUint8(_base + offset);
« no previous file with comments | « mojo/dart/embedder/mojo_natives.cc ('k') | mojo/public/dart/mojo/lib/src/message.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698