mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 02:00:51 +00:00
Removing unneeded if statement
This commit is contained in:
parent
8572255e73
commit
c3676bc6f9
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user