wee allocator
This commit is contained in:
		
							parent
							
								
									8c8b5d0b8f
								
							
						
					
					
						commit
						725381c07c
					
				
					 4 changed files with 30 additions and 6 deletions
				
			
		
							
								
								
									
										19
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										19
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							|  | @ -244,6 +244,7 @@ dependencies = [ | |||
|  "js-sys", | ||||
|  "wasm-bindgen", | ||||
|  "web-sys", | ||||
|  "wee_alloc", | ||||
|  "yew", | ||||
| ] | ||||
| 
 | ||||
|  | @ -299,6 +300,12 @@ dependencies = [ | |||
|  "cfg-if 0.1.10", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "memory_units" | ||||
| version = "0.4.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "miniz_oxide" | ||||
| version = "0.4.3" | ||||
|  | @ -569,6 +576,18 @@ dependencies = [ | |||
|  "wasm-bindgen", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "wee_alloc" | ||||
| version = "0.4.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" | ||||
| dependencies = [ | ||||
|  "cfg-if 0.1.10", | ||||
|  "libc", | ||||
|  "memory_units", | ||||
|  "winapi", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "winapi" | ||||
| version = "0.3.9" | ||||
|  |  | |||
|  | @ -15,6 +15,7 @@ gpx = "0.8.1" | |||
| # yew = "0.19" | ||||
| yew = { git = "https://github.com/yewstack/yew.git" } | ||||
| gloo-file = "0.2" | ||||
| wee_alloc = "0.4" | ||||
| 
 | ||||
| console_error_panic_hook = { version = "0.1.6", optional = true } | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ use std::collections::HashMap; | |||
| 
 | ||||
| use gloo_file::callbacks::FileReader; | ||||
| use gloo_file::File; | ||||
| use web_sys::{Event, HtmlInputElement, MouseEvent, Url}; | ||||
| use web_sys::{Event, HtmlInputElement, Url, MouseEvent}; | ||||
| use yew::{html, html::TargetCast, Component, Context, Html}; | ||||
| 
 | ||||
| use super::utils; | ||||
|  | @ -83,7 +83,7 @@ impl Component for Loader { | |||
|                     Err(err) => { | ||||
|                         utils::alert(&err.to_string()); | ||||
|                         ctx.link().send_message(Msg::Reset); | ||||
|                         return true; | ||||
|                         return true | ||||
|                     } | ||||
|                 }; | ||||
| 
 | ||||
|  | @ -94,9 +94,7 @@ impl Component for Loader { | |||
|                 let url = Url::create_object_url_with_blob(&merged).unwrap(); | ||||
| 
 | ||||
|                 anchor_element.set_attribute("href", &url).unwrap(); | ||||
|                 anchor_element | ||||
|                     .set_attribute("download", "merged.gpx") | ||||
|                     .unwrap(); | ||||
|                 anchor_element.set_attribute("download", "merged.gpx").unwrap(); | ||||
| 
 | ||||
|                 self.is_loading = false; | ||||
| 
 | ||||
|  | @ -122,7 +120,7 @@ impl Component for Loader { | |||
|         let link = ctx.link(); | ||||
|         html! { | ||||
|             if self.is_loading { | ||||
|                 <span>{"loading..."}</span> | ||||
|                 <span><strong>{"processing..."}</strong></span> | ||||
|             } else { | ||||
|                 <input type="file" value={self.field_value} multiple=true onchange={link.callback(move |e: Event| { | ||||
|                     let mut result = Vec::new(); | ||||
|  |  | |||
|  | @ -1,7 +1,13 @@ | |||
| extern crate wee_alloc; | ||||
| 
 | ||||
| mod app; | ||||
| mod loader; | ||||
| mod utils; | ||||
| 
 | ||||
| // Use `wee_alloc` as the global allocator.
 | ||||
| #[global_allocator] | ||||
| static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; | ||||
| 
 | ||||
| fn main() { | ||||
|     yew::start_app::<app::App>(); | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue