Migrate to hashbrown structures
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::collections::HashMap;
|
use hashbrown::HashMap;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ImportData(pub(crate) Vec<ImportGroup>);
|
pub struct ImportData(pub(crate) Vec<ImportGroup>);
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ use iced::widget::*;
|
|||||||
use iced::{Border, Color, Shadow, Task};
|
use iced::{Border, Color, Shadow, Task};
|
||||||
use iced_core::Length::Fill;
|
use iced_core::Length::Fill;
|
||||||
use rand::random_range;
|
use rand::random_range;
|
||||||
use std::collections::{HashMap, HashSet};
|
use hashbrown::{HashMap, HashSet};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ use iced_core::window::Position;
|
|||||||
use iced_core::window::settings::PlatformSpecific;
|
use iced_core::window::settings::PlatformSpecific;
|
||||||
use mimalloc::MiMalloc;
|
use mimalloc::MiMalloc;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
use std::collections::HashMap;
|
use hashbrown::HashMap;
|
||||||
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL: MiMalloc = MiMalloc;
|
static GLOBAL: MiMalloc = MiMalloc;
|
||||||
|
|||||||
+4
-2
@@ -27,7 +27,7 @@ use chrono::NaiveDate;
|
|||||||
use iced::keyboard::Event;
|
use iced::keyboard::Event;
|
||||||
use iced::{Element, Task};
|
use iced::{Element, Task};
|
||||||
use reqwest::Error;
|
use reqwest::Error;
|
||||||
use std::collections::HashMap;
|
use hashbrown::HashMap;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
@@ -171,7 +171,9 @@ impl ScreenState {
|
|||||||
if let UpdateData = message {
|
if let UpdateData = message {
|
||||||
println!("Loading data");
|
println!("Loading data");
|
||||||
let mut state = self.app_state.lock().unwrap();
|
let mut state = self.app_state.lock().unwrap();
|
||||||
state.connection = Connection::open_in_memory().unwrap();
|
if cfg!(windows){
|
||||||
|
state.connection = Connection::open_in_memory().unwrap();
|
||||||
|
}
|
||||||
let path = app_data_dir();
|
let path = app_data_dir();
|
||||||
let db_file = path.join("data.db");
|
let db_file = path.join("data.db");
|
||||||
let temp_db_file = path.join("data.db.tmp");
|
let temp_db_file = path.join("data.db.tmp");
|
||||||
|
|||||||
@@ -97,9 +97,7 @@ impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|c| self.word_id_index_map[&c.word_id])
|
.map(|c| self.word_id_index_map[&c.word_id])
|
||||||
.collect();
|
.collect();
|
||||||
println!("Already exists {:?}", added);
|
|
||||||
let total = set.get_word_list(&state);
|
let total = set.get_word_list(&state);
|
||||||
println!("Available{:?}", total);
|
|
||||||
|
|
||||||
self.current_sets_cards_cache.insert(index, (added, total));
|
self.current_sets_cards_cache.insert(index, (added, total));
|
||||||
|
|
||||||
@@ -164,14 +162,6 @@ impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
|
|||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
for x in &cache.0 {
|
|
||||||
println!("Already exists {:?}", state.dictionary.get(*x).unwrap());
|
|
||||||
}
|
|
||||||
|
|
||||||
for w in &adding {
|
|
||||||
println!("{:?}", state.dictionary.get(*w).unwrap());
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut new_current = cache.0.clone();
|
let mut new_current = cache.0.clone();
|
||||||
new_current.append(&mut adding.clone());
|
new_current.append(&mut adding.clone());
|
||||||
total_cache.insert(index, (new_current, cache.1.clone()));
|
total_cache.insert(index, (new_current, cache.1.clone()));
|
||||||
|
|||||||
Reference in New Issue
Block a user