Skip to content

[objective_c] fix toNSInputStream double copy - #3762

Merged
brianquinlan merged 6 commits into
dart-lang:mainfrom
brianquinlan:buffer_coallese
Oct 30, 2026
Merged

brianquinlan merged 6 commits into
dart-lang:mainfrom
brianquinlan:buffer_coallese

Conversation

@brianquinlan

@brianquinlan brianquinlan commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Currently the NSInputStream returned by toNSInputStream does unnecessary copies for every byte that is accessed through read:maxLength:

  1. addData, which is called from Dart, appends an NSData to the end of the _data buffer
  2. read:maxLength shifts the data in _data after every read

This change maintains an array of NSData to avoid those two copies.

PR Checklist

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
  • I've run dart tool/ci.dart --all locally and resolved all issues identified. This ensures the PR is formatted, has no lint errors, and ran all code generators. This applies to the packages part of the toplevel pubspec.yaml workspace.
  • All existing and new tests are passing. I added new tests to check the change I am making.
  • The PR is actually solving the issue. PRs that don't solve the issue will be closed. Please be respectful of the maintainers' time. If it's not clear what the issue is, feel free to ask questions on the GitHub issue before submitting a PR.
  • I have updated CHANGELOG.md for the relevant packages. (Not needed for small changes such as doc typos).
  • I have updated the pubspec package version if necessary.

@brianquinlan brianquinlan changed the title [objective_c] [objective_c] fix toNSInputStream double copy Oct 23, 2026
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.91%. Comparing base (63f3e86) to head (40cd9fe).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3762      +/-   ##
==========================================
+ Coverage   85.84%   87.91%   +2.06%     
==========================================
  Files         322      310      -12     
  Lines       20877    19789    -1088     
==========================================
- Hits        17922    17397     -525     
+ Misses       2955     2392     -563     
Flag Coverage Δ
ffigen 91.36% <ø> (ø)
objective_c 62.87% <ø> (ø)
swiftgen 80.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
code_assets 94.86% <ø> (-0.46%) ⬇️
data_assets 91.56% <ø> (ø)
ffi 100.00% <ø> (ø)
ffigen 91.45% <ø> (ø)
hooks 86.40% <ø> (ø)
hooks_runner 90.35% <ø> (-0.17%) ⬇️
jni 66.34% <ø> (ø)
jni_flutter ∅ <ø> (∅)
jni_util 25.00% <ø> (ø)
jnigen 82.85% <ø> (ø)
json_syntax_generator ∅ <ø> (∅)
native_test_helpers 85.71% <ø> (ø)
native_toolchain_c 95.89% <ø> (-0.10%) ⬇️
objective_c 79.56% <ø> (ø)
pub_formats ∅ <ø> (∅)
record_use 81.48% <ø> (ø)
snippet_tool 66.23% <ø> (ø)
swift2objc 92.95% <ø> (ø)
swiftgen 80.41% <ø> (ø)
test_case_selector 97.28% <ø> (ø)
see 19 files with indirect coverage changes
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

# Conflicts:
#	pkgs/objective_c/CHANGELOG.md
#	pkgs/objective_c/src/input_stream_adapter.m
@brianquinlan
brianquinlan merged commit 264318e into dart-lang:main Oct 30, 2026
55 of 56 checks passed
copybara-service Bot pushed a commit to dart-lang/sdk that referenced this pull request Nov 4, 2026
Revisions updated by `dart tools/rev_sdk_deps.dart native`.

native (https://github.com/dart-lang/native/compare/e0ca7c6..b442038):
  b442038de  Mon Nov 2 10:46:15 2026 -0800  Brian Quinlan  [objective_c] support `scheduleInRunLoop:forMode:` (dart-lang/native#3763)
  264318e75  Fri Oct 30 12:49:03 2026 -0700  Brian Quinlan  [objective_c] fix `toNSInputStream` double copy (dart-lang/native#3762)
  63f3e8641  Fri Oct 30 12:09:04 2026 -0700  Brian Quinlan  [objective_c] avoid an extra copy in `toNSData`  (dart-lang/native#3761)
  ad203b01d  Fri Oct 30 11:48:15 2026 -0700  Brian Quinlan  [objective_c] increase read chunk size (dart-lang/native#3760)
  fa112d95b  Fri Oct 30 09:14:23 2026 -0700  Brian Quinlan  [objective_c] Fix a `NSInputStream` hang (dart-lang/native#3751)
  035f4ef38  Fri Oct 30 09:23:30 2026 +0100  Michael Goderbauer  [jnigen] Fix race conditions in tests (dart-lang/native#3767)
  d58a8f514  Fri Oct 30 00:57:49 2026 -0400  Jhin Lee  [code_assets] Preserve full Apple deployment versions (dart-lang/native#3742)

Migrate `MacOSCodeConfig` in `pkg/dartdev/lib/src/native_assets.dart` from the
deprecated `targetVersion` parameter to `deploymentVersion: AppleVersion(...)`.

Change-Id: I2df469fc05bda2c1db051f43e803fe5145f7c246
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/573102
Auto-Submit: Nate Bosch <[email protected]>
Reviewed-by: Nicholas Shahan <[email protected]>
Reviewed-by: Ben Konyi <[email protected]>
Commit-Queue: Ben Konyi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants