Removing unneeded if statement

This commit is contained in:
Pauan 2019-07-18 00:11:40 +02:00
parent 8572255e73
commit c3676bc6f9

View File

@ -1096,12 +1096,18 @@ impl<'a> Context<'a> {
self.expose_get_object();
self.expose_get_string_from_wasm()?;
// This has support for both `&str` and `Option<&str>`.
//
// If `ptr` is not `0` then we know that it's a `&str` or `Some(&str)`, so we just decode it.
//
// If `ptr` is `0` then the `len` is a pointer to the cached `JsValue`, so we return that.
//
// If `ptr` and `len` are both `0` then that means it's `None`, in that case we rely upon
// the fact that `getObject(0)` is guaranteed to be `undefined`.
self.global("
function getCachedStringFromWasm(ptr, len) {
if (ptr === 0) {
if (len !== 0) {
return getObject(len);
}
return getObject(len);
} else {
return getStringFromWasm(ptr, len);
}