mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-15 22:11:23 +00:00
Only generate JS null checks in debug mode
In non-debug mode Rust is already checking these pointers, so let's only generate the relevant code in debug mode.
This commit is contained in:
@ -68,11 +68,13 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
||||
/// passed should be `this.ptr`.
|
||||
pub fn method(&mut self, method: bool, consumed: bool) -> &mut Self {
|
||||
if method {
|
||||
self.prelude(
|
||||
"if (this.ptr === 0) {
|
||||
throw new Error('Attempt to use a moved value');
|
||||
}",
|
||||
);
|
||||
if self.cx.config.debug {
|
||||
self.prelude(
|
||||
"if (this.ptr === 0) {
|
||||
throw new Error('Attempt to use a moved value');
|
||||
}",
|
||||
);
|
||||
}
|
||||
if consumed {
|
||||
self.prelude(
|
||||
"\
|
||||
|
Reference in New Issue
Block a user