Skip to content

Commit 589e5ba

Browse files
committed
chore: comment on optimize buffer handling in start_task to reduce copying for larger responses
1 parent 86243bc commit 589e5ba

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/wkwebview/class/url_scheme_handler.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ extern "C" fn start_task(
267267
.map_err(|_e| crate::Error::CustomProtocolTaskInvalid)?;
268268

269269
let content = sent_response.into_body();
270+
// It yields benefits by eliminating buffer copying starting from 88 bytes.
271+
// However, sizes below 88 bytes cause regressions. 128 bytes as
272+
// it aligns better with engineering standards and is more human-readable.
270273
let data = if content_len < NO_COPY_DATA_THRESHOLD {
271274
// Keep small responses on the original copy path; no-copy deallocation costs more.
272275
NSData::with_bytes(content.as_ref())

0 commit comments

Comments
 (0)