mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 02:00:51 +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]
|
||||
#[inline(never)]
|
||||
pub fn throw(s: &str) -> ! {
|
||||
extern {
|
||||
fn __wbindgen_throw(a: *const u8, b: usize) -> !;
|
||||
@ -72,10 +73,16 @@ pub mod __rt {
|
||||
#[inline]
|
||||
pub fn assert_not_null<T>(s: *mut T) {
|
||||
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.
|
||||
///
|
||||
/// Now why, you may ask, would we do that? Surely `RefCell` in libstd is
|
||||
|
Loading…
x
Reference in New Issue
Block a user