This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +8
-8
lines changed
third_party/tonic/typed_data Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -49,9 +49,10 @@ void PlatformMessageResponseDart::Complete(std::unique_ptr<fml::Mapping> data) {
49
49
tonic::DartState::Scope scope (dart_state);
50
50
51
51
void * mapping = data->GetMutableMapping ();
52
+ size_t data_size = data->GetSize ();
52
53
Dart_Handle byte_buffer;
53
- if (mapping) {
54
- size_t data_size = data-> GetSize ();
54
+ if (mapping &&
55
+ data_size >= tonic::DartByteData:: kExternalSizeThreshold ) {
55
56
byte_buffer = Dart_NewExternalTypedDataWithFinalizer (
56
57
/* type=*/ Dart_TypedData_kByteData,
57
58
/* data=*/ mapping,
Original file line number Diff line number Diff line change 11
11
namespace tonic {
12
12
13
13
namespace {
14
-
15
- // For large objects it is more efficient to use an external typed data object
16
- // with a buffer allocated outside the Dart heap.
17
- const int kExternalSizeThreshold = 1000 ;
18
-
19
14
void FreeFinalizer (void * isolate_callback_data, void * peer) {
20
15
free (peer);
21
16
}
22
-
23
17
} // anonymous namespace
24
18
19
+ // For large objects it is more efficient to use an external typed data object
20
+ // with a buffer allocated outside the Dart heap.
21
+ const size_t DartByteData::kExternalSizeThreshold = 1000 ;
22
+
25
23
Dart_Handle DartByteData::Create (const void * data, size_t length) {
26
24
if (length < kExternalSizeThreshold ) {
27
25
auto handle = DartByteData{data, length}.dart_handle ();
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ namespace tonic {
14
14
15
15
class DartByteData {
16
16
public:
17
+ static const size_t kExternalSizeThreshold ;
17
18
static Dart_Handle Create (const void * data, size_t length);
18
19
19
20
explicit DartByteData (Dart_Handle list);
You can’t perform that action at this time.
0 commit comments