change to hashbrown

This commit is contained in:
Dongdong Zhou 2021-11-02 16:31:53 +00:00
parent 57e2db04d1
commit e644db9b2c
3 changed files with 27 additions and 16 deletions

24
Cargo.lock generated
View File

@ -35,6 +35,17 @@ version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e"
[[package]]
name = "ahash"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [
"getrandom",
"once_cell",
"version_check",
]
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "0.7.18" version = "0.7.18"
@ -1045,7 +1056,6 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
[[package]] [[package]]
name = "druid" name = "druid"
version = "0.7.0" version = "0.7.0"
source = "git+https://github.com/lapce/druid#fe2dd72929edc534ece197ee4f8160a747c2a375"
dependencies = [ dependencies = [
"console_error_panic_hook", "console_error_panic_hook",
"druid-derive", "druid-derive",
@ -1069,7 +1079,6 @@ dependencies = [
[[package]] [[package]]
name = "druid-derive" name = "druid-derive"
version = "0.4.0" version = "0.4.0"
source = "git+https://github.com/lapce/druid#fe2dd72929edc534ece197ee4f8160a747c2a375"
dependencies = [ dependencies = [
"proc-macro2 1.0.29", "proc-macro2 1.0.29",
"quote 1.0.9", "quote 1.0.9",
@ -1079,7 +1088,6 @@ dependencies = [
[[package]] [[package]]
name = "druid-shell" name = "druid-shell"
version = "0.7.0" version = "0.7.0"
source = "git+https://github.com/lapce/druid#fe2dd72929edc534ece197ee4f8160a747c2a375"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cfg-if 1.0.0", "cfg-if 1.0.0",
@ -1626,7 +1634,7 @@ version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
dependencies = [ dependencies = [
"ahash", "ahash 0.4.7",
] ]
[[package]] [[package]]
@ -1634,6 +1642,9 @@ name = "hashbrown"
version = "0.11.2" version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
dependencies = [
"ahash 0.7.6",
]
[[package]] [[package]]
name = "heck" name = "heck"
@ -1958,6 +1969,7 @@ dependencies = [
"druid", "druid",
"fuzzy-matcher", "fuzzy-matcher",
"fzyr", "fzyr",
"hashbrown 0.11.2",
"im", "im",
"include_dir", "include_dir",
"indexmap", "indexmap",
@ -1968,7 +1980,6 @@ dependencies = [
"lsp-types", "lsp-types",
"parking_lot 0.11.2", "parking_lot 0.11.2",
"regex", "regex",
"rustc-hash",
"serde 1.0.130", "serde 1.0.130",
"serde_json", "serde_json",
"sled", "sled",
@ -2969,19 +2980,18 @@ dependencies = [
[[package]] [[package]]
name = "piet-wgpu" name = "piet-wgpu"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/lapce/piet-wgpu#beb68d2cecfd810ff5cbe1e9cd4e471ef6b7f506"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"font-kit", "font-kit",
"futures", "futures",
"glam", "glam",
"hashbrown 0.11.2",
"include_dir", "include_dir",
"linked-hash-map", "linked-hash-map",
"lyon", "lyon",
"pathfinder_geometry", "pathfinder_geometry",
"piet", "piet",
"raw-window-handle", "raw-window-handle",
"rustc-hash",
"sha2 0.9.8", "sha2 0.9.8",
"unicode-width", "unicode-width",
"usvg", "usvg",

View File

@ -5,7 +5,7 @@ authors = ["Dongdong Zhou <dzhou121@gmail.com>"]
edition = "2021" edition = "2021"
[dependencies] [dependencies]
rustc-hash = "1.1.0" hashbrown = "0.11.2"
sled = "0.34.7" sled = "0.34.7"
base64 = "0.13.0" base64 = "0.13.0"
alacritty_terminal = "0.15.0" alacritty_terminal = "0.15.0"

View File

@ -1,4 +1,4 @@
use std::{collections::HashMap, io::Write, path::PathBuf}; use std::{io::Write, path::PathBuf};
use anyhow::Result; use anyhow::Result;
use directories::ProjectDirs; use directories::ProjectDirs;
@ -6,7 +6,7 @@
piet::{PietText, Text, TextLayout, TextLayoutBuilder}, piet::{PietText, Text, TextLayout, TextLayoutBuilder},
theme, Color, Env, FontDescriptor, FontFamily, Key, Size, theme, Color, Env, FontDescriptor, FontFamily, Key, Size,
}; };
use rustc_hash::FxHashMap; use hashbrown::HashMap;
use serde::{Deserialize, Deserializer, Serialize}; use serde::{Deserialize, Deserializer, Serialize};
use crate::{ use crate::{
@ -98,9 +98,9 @@ pub struct Config {
pub lapce: LapceConfig, pub lapce: LapceConfig,
pub editor: EditorConfig, pub editor: EditorConfig,
#[serde(skip)] #[serde(skip)]
pub theme: FxHashMap<String, Color>, pub theme: HashMap<String, Color>,
#[serde(skip)] #[serde(skip)]
pub themes: FxHashMap<String, FxHashMap<String, Color>>, pub themes: HashMap<String, HashMap<String, Color>>,
} }
impl Config { impl Config {
@ -129,7 +129,7 @@ pub fn load(workspace: Option<LapceWorkspace>) -> Result<Self> {
config.theme = get_theme(default_light_theme)?; config.theme = get_theme(default_light_theme)?;
let mut themes = HashMap::default(); let mut themes = HashMap::new();
themes.insert("Lapce Light".to_string(), get_theme(default_light_theme)?); themes.insert("Lapce Light".to_string(), get_theme(default_light_theme)?);
themes.insert("Lapce Dark".to_string(), get_theme(default_dark_theme)?); themes.insert("Lapce Dark".to_string(), get_theme(default_dark_theme)?);
config.themes = themes; config.themes = themes;
@ -353,9 +353,10 @@ pub fn recent_workspaces_file() -> Option<PathBuf> {
} }
} }
fn get_theme(content: &str) -> Result<FxHashMap<String, Color>> { fn get_theme(content: &str) -> Result<HashMap<String, Color>> {
let theme_colors: FxHashMap<String, String> = toml::from_str(content)?; let theme_colors: std::collections::HashMap<String, String> =
let mut theme = HashMap::default(); toml::from_str(content)?;
let mut theme = HashMap::new();
for (k, v) in theme_colors.iter() { for (k, v) in theme_colors.iter() {
if v.starts_with("$") { if v.starts_with("$") {
let var_name = &v[1..]; let var_name = &v[1..];