[core/shared] Mark _CopyingBytesBuilder._emptyList shared

This enables use of BytesBuilder in isolategroup-bound callbacks.

TEST=run_isolate_group_run_test
CoreLibraryReviewExempt: this adds vm-specific pragma
Bug: https://github.com/dart-lang/sdk/issues/61030
Change-Id: Ic73887af099e6a7636e939d378dbe08a2f0c8f98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476601
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
This commit is contained in:
Alexander Aprelev
2026-01-29 14:31:47 -08:00
committed by Commit Queue
parent 4c188f9aac
commit 27d4f2c79d
2 changed files with 13 additions and 0 deletions
+1
View File
@@ -74,6 +74,7 @@ class _CopyingBytesBuilder implements BytesBuilder {
/// Reusable empty [Uint8List].
///
/// Safe for reuse because a fixed-length empty list is immutable.
@pragma('vm:shared')
static final _emptyList = Uint8List(0);
/// Current count of bytes written to buffer.
+12
View File
@@ -15,6 +15,7 @@
import 'package:dart_internal/isolate_group.dart' show IsolateGroup;
import 'dart:convert';
import 'dart:developer';
import 'dart:io';
import 'dart:isolate';
import 'dart:math';
@@ -68,6 +69,8 @@ main(List<String> args) {
testEncoding();
testRecursiveToString();
testBytesBuilder();
print("All tests completed :)");
}
@@ -523,3 +526,12 @@ void testRecursiveToString() {
}),
);
}
///
void testBytesBuilder() {
BytesBuilder builder = new BytesBuilder();
builder.add([1, 2, 3]);
Expect.listEquals([1, 2, 3], builder.toBytes());
builder.clear();
Expect.isTrue(builder.isEmpty);
}