Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion dart/lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'types.dart';

/// The main builder class for creation of a FlexBuffer.
class Builder {
final ByteData _buffer;
ByteData _buffer;
List<_StackValue> _stack = [];
List<_StackPointer> _stackPointers = [];
int _offset = 0;
Expand Down Expand Up @@ -506,6 +506,7 @@ class Builder {
if (prevSize < size) {
final newBuf = ByteData(size);
newBuf.buffer.asUint8List().setAll(0, _buffer.buffer.asUint8List());
_buffer = newBuf;
}
return newOffset;
}
Expand Down
15 changes: 15 additions & 0 deletions dart/test/flex_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,21 @@ void main() {
1,
]);
}
{
// Default buffer is 2048 bytes, add 2300 bytes of strings that force it
// to grow.
final s1 = 'A' * 1000;
final s2 = 'B' * 800;
final s3 = 'C' * 500;

var flx = Builder()
..startVector()
..addString(s1)
..addString(s2)
..addString(s3)
..end();
expect(flx.finish().length, 2323);
}
});

test('build map', () {
Expand Down
Loading