Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
38f360f9
Unverified
Commit
38f360f9
authored
Apr 13, 2022
by
gaaclarke
Committed by
GitHub
Apr 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Increased WriteBuffers starting capacity to 64 bytes. (#101790)
parent
88724e59
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
3 deletions
+13
-3
serialization.dart
packages/flutter/lib/src/foundation/serialization.dart
+6
-2
message_codecs.dart
packages/flutter/lib/src/services/message_codecs.dart
+1
-1
serialization_test.dart
packages/flutter/test/foundation/serialization_test.dart
+6
-0
No files found.
packages/flutter/lib/src/foundation/serialization.dart
View file @
38f360f9
...
...
@@ -13,10 +13,14 @@ import 'dart:typed_data';
/// The byte order used is [Endian.host] throughout.
class
WriteBuffer
{
/// Creates an interface for incrementally building a [ByteData] instance.
factory
WriteBuffer
()
{
/// [startCapacity] determines the start size of the [WriteBuffer] in bytes.
/// The closer that value is to the real size used, the better the
/// performance.
factory
WriteBuffer
({
int
startCapacity
=
8
})
{
assert
(
startCapacity
>
0
);
final
ByteData
eightBytes
=
ByteData
(
8
);
final
Uint8List
eightBytesAsList
=
eightBytes
.
buffer
.
asUint8List
();
return
WriteBuffer
.
_
(
Uint8List
(
8
),
eightBytes
,
eightBytesAsList
);
return
WriteBuffer
.
_
(
Uint8List
(
startCapacity
),
eightBytes
,
eightBytesAsList
);
}
WriteBuffer
.
_
(
this
.
_buffer
,
this
.
_eightBytes
,
this
.
_eightBytesAsList
);
...
...
packages/flutter/lib/src/services/message_codecs.dart
View file @
38f360f9
...
...
@@ -310,7 +310,7 @@ class StandardMessageCodec implements MessageCodec<Object?> {
ByteData
?
encodeMessage
(
Object
?
message
)
{
if
(
message
==
null
)
return
null
;
final
WriteBuffer
buffer
=
WriteBuffer
();
final
WriteBuffer
buffer
=
WriteBuffer
(
startCapacity:
64
);
writeValue
(
buffer
,
message
);
return
buffer
.
done
();
}
...
...
packages/flutter/test/foundation/serialization_test.dart
View file @
38f360f9
...
...
@@ -124,5 +124,11 @@ void main() {
write
.
done
();
expect
(()
=>
write
.
done
(),
throwsStateError
);
});
test
(
'empty WriteBuffer'
,
()
{
expect
(()
=>
WriteBuffer
(
startCapacity:
0
),
throwsAssertionError
);
});
test
(
'size 1'
,
()
{
expect
(()
=>
WriteBuffer
(
startCapacity:
1
),
returnsNormally
);
});
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment