From 44a955531392eca6c502e3da97de2dce49cf90ae Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 21 Dec 2017 12:25:13 -0800 Subject: [PATCH] Extract null check throw to a separate function Slightly smaller callsite! --- src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 608ee525..c2f44a07 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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(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