This commit is contained in:
Simon Gardling
2023-03-25 23:48:10 -04:00
parent caba881a95
commit b9367a7de8
3 changed files with 17 additions and 17 deletions

View File

@@ -43,9 +43,9 @@ cfg_if::cfg_if! {
if #[cfg(target_arch = "wasm32")] {
use wasm_bindgen::prelude::*;
use lol_alloc::{FreeListAllocator, LockedAllocator};
use lol_alloc::{FreeListAllocator, AssumeSingleThreaded};
#[global_allocator]
static ALLOCATOR: LockedAllocator<FreeListAllocator> = LockedAllocator::new(FreeListAllocator::new());
static ALLOCATOR: AssumeSingleThreaded<FreeListAllocator> = unsafe { AssumeSingleThreaded::new(FreeListAllocator::new()) };
#[wasm_bindgen(start)]
pub async fn start() {

View File

@@ -379,16 +379,16 @@ impl MathApp {
#[cfg(target_arch = "wasm32")]
{
tracing::info!("Saving function data");
let hash: crate::misc::HashBytes = unsafe {
std::mem::transmute::<&str, crate::misc::HashBytes>(build::SHORT_COMMIT)
};
let saved_data = &crate::misc::hashed_storage_create(
&hash,
bincode::serialize(&self.functions).unwrap().as_slice(),
use crate::misc::{HashBytes, HashBytesHelper};
let hash: HashBytes =
unsafe { std::mem::transmute::<&str, HashBytes>(build::SHORT_COMMIT) };
let saved_data = hash.hashed_storage_create(
&bincode::serialize(&self.functions)
.expect("unable to deserialize functions"),
);
// tracing::info!("Bytes: {}", saved_data.len());
get_localstorage()
.set_item(FUNC_NAME, saved_data)
.set_item(FUNC_NAME, &saved_data)
.expect("failed to set local function storage");
}
}