diff --git a/src/embind/embind.js b/src/embind/embind.js index d9035d788e5af..c6f8c4fa79488 100644 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -642,11 +642,13 @@ var LibraryEmbind = { return value; }, 'toWireType': function(destructors, value) { - // todo: Here we have an opportunity for -O3 level "unsafe" optimizations: we could - // avoid the following if() and assume value is of proper type. +#if ASSERTIONS if (typeof value !== "number" && typeof value !== "boolean") { throw new TypeError('Cannot convert "' + _embind_repr(value) + '" to ' + this.name); } +#endif + // The VM will perform JS to Wasm value conversion, according to the spec: + // https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue return value; }, 'argPackAdvance': 8,