mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-01 18:01:06 +00:00
Extract null check throw to a separate function
Slightly smaller callsite!
This commit is contained in:
parent
6aacff6a80
commit
44a9555313
@ -55,6 +55,7 @@ impl Drop for JsObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cold]
|
#[cold]
|
||||||
|
#[inline(never)]
|
||||||
pub fn throw(s: &str) -> ! {
|
pub fn throw(s: &str) -> ! {
|
||||||
extern {
|
extern {
|
||||||
fn __wbindgen_throw(a: *const u8, b: usize) -> !;
|
fn __wbindgen_throw(a: *const u8, b: usize) -> !;
|
||||||
@ -72,10 +73,16 @@ pub mod __rt {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn assert_not_null<T>(s: *mut T) {
|
pub fn assert_not_null<T>(s: *mut T) {
|
||||||
if s.is_null() {
|
if s.is_null() {
|
||||||
super::throw("null pointer passed to rust");
|
throw_null();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cold]
|
||||||
|
#[inline(never)]
|
||||||
|
fn throw_null() -> ! {
|
||||||
|
super::throw("null pointer passed to rust");
|
||||||
|
}
|
||||||
|
|
||||||
/// A vendored version of `RefCell` from the standard library.
|
/// A vendored version of `RefCell` from the standard library.
|
||||||
///
|
///
|
||||||
/// Now why, you may ask, would we do that? Surely `RefCell` in libstd is
|
/// Now why, you may ask, would we do that? Surely `RefCell` in libstd is
|
||||||
|
Loading…
x
Reference in New Issue
Block a user