Skip to content

Commit 3042ef1

Browse files
committed
refatcor: mirage NSData::initWithBytes_length to NSData::with_bytes
1 parent 2edf3f9 commit 3042ef1

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

src/wkwebview/class/url_scheme_handler.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use std::{
66
borrow::Cow,
7-
ffi::{c_char, c_void, CStr},
7+
ffi::{c_char, CStr},
88
panic::AssertUnwindSafe,
99
ptr::NonNull,
1010
};
@@ -268,20 +268,14 @@ extern "C" fn start_task(
268268
.map_err(|_e| crate::Error::CustomProtocolTaskInvalid)?;
269269

270270
let data = if content_len < NO_COPY_DATA_THRESHOLD {
271-
let data = NSData::alloc();
272271
// Keep small responses on the original copy path; no-copy deallocation costs more.
273-
NSData::initWithBytes_length(data, content.as_ptr() as *mut c_void, content.len())
272+
NSData::with_bytes(content)
274273
} else {
275274
match sent_response.into_body() {
276275
Cow::Owned(content) => NSData::from_vec(content),
277276
Cow::Borrowed(content) => {
278-
let data = NSData::alloc();
279277
// Copy borrowed responses because NSData cannot take ownership.
280-
NSData::initWithBytes_length(
281-
data,
282-
content.as_ptr() as *mut c_void,
283-
content.len(),
284-
)
278+
NSData::with_bytes(content)
285279
}
286280
}
287281
};

0 commit comments

Comments
 (0)