mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-08 18:30:40 +00:00
Replace hashbrown with std+ahash
This commit is contained in:
parent
4623e40dab
commit
565c64c528
@ -35,8 +35,8 @@ term_size = { version = "0.3.1", optional = true }
|
||||
crossbeam-channel = "0.3.9"
|
||||
lazy_static = "1.3.0"
|
||||
chrono = "0.4.7"
|
||||
hashbrown = "0.5.0"
|
||||
cfg-if = "0.1.9"
|
||||
ahash = "0.2.12"
|
||||
|
||||
[dependencies.num]
|
||||
default-features = false
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
use bear_lib_terminal;
|
||||
|
||||
use hashbrown::HashSet;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use self::bear_lib_terminal::geometry::Size;
|
||||
use self::bear_lib_terminal::terminal::{
|
||||
@ -18,6 +18,9 @@ use crate::event::{Event, Key, MouseButton, MouseEvent};
|
||||
use crate::theme::{BaseColor, Color, ColorPair, Effect};
|
||||
use crate::vec::Vec2;
|
||||
|
||||
// Use AHash instead of the slower SipHash
|
||||
type HashMap<K, V> = std::collections::HashMap<K, V, ahash::ABuildHasher>;
|
||||
|
||||
enum ColorRole {
|
||||
Foreground,
|
||||
Background,
|
||||
@ -47,7 +50,7 @@ impl Backend {
|
||||
]);
|
||||
|
||||
let c = Backend {
|
||||
buttons_pressed: HashSet::new(),
|
||||
buttons_pressed: HashSet::default(),
|
||||
mouse_position: Vec2::zero(),
|
||||
};
|
||||
|
||||
|
@ -3,8 +3,6 @@
|
||||
//! Requires either of `ncurses-backend` or `pancurses-backend`.
|
||||
#![cfg(any(feature = "ncurses-backend", feature = "pancurses-backend"))]
|
||||
|
||||
use hashbrown::HashMap;
|
||||
|
||||
use crate::event::{Event, Key};
|
||||
use crate::theme::{BaseColor, Color, ColorPair};
|
||||
use maplit::hashmap;
|
||||
@ -15,6 +13,9 @@ pub mod n;
|
||||
#[cfg(feature = "pancurses-backend")]
|
||||
pub mod pan;
|
||||
|
||||
// Use AHash instead of the slower SipHash
|
||||
type HashMap<K, V> = std::collections::HashMap<K, V, ahash::ABuildHasher>;
|
||||
|
||||
fn split_i32(code: i32) -> Vec<u8> {
|
||||
(0..4).map(|i| ((code >> (8 * i)) & 0xFF) as u8).collect()
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
use log::{debug, warn};
|
||||
use ncurses;
|
||||
|
||||
use hashbrown::HashMap;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::ffi::CString;
|
||||
use std::fs::File;
|
||||
@ -20,6 +19,9 @@ use crate::vec::Vec2;
|
||||
use self::super::split_i32;
|
||||
use self::ncurses::mmask_t;
|
||||
|
||||
// Use AHash instead of the slower SipHash
|
||||
type HashMap<K, V> = std::collections::HashMap<K, V, ahash::ABuildHasher>;
|
||||
|
||||
/// Backend using ncurses.
|
||||
pub struct Backend {
|
||||
current_style: Cell<ColorPair>,
|
||||
@ -117,7 +119,7 @@ impl Backend {
|
||||
|
||||
let c = Backend {
|
||||
current_style: Cell::new(ColorPair::from_256colors(0, 0)),
|
||||
pairs: RefCell::new(HashMap::new()),
|
||||
pairs: RefCell::new(HashMap::default()),
|
||||
key_codes: initialize_keymap(),
|
||||
last_mouse_button: None,
|
||||
input_buffer: None,
|
||||
@ -458,7 +460,8 @@ where
|
||||
|
||||
fn initialize_keymap() -> HashMap<i32, Event> {
|
||||
// First, define the static mappings.
|
||||
let mut map = HashMap::new();
|
||||
let mut map = HashMap::default();
|
||||
|
||||
// Value sent by ncurses when nothing happens
|
||||
map.insert(-1, Event::Refresh);
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
use log::{debug, warn};
|
||||
use pancurses;
|
||||
|
||||
use hashbrown::HashMap;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::io::{stdout, Write};
|
||||
|
||||
@ -14,6 +13,9 @@ use crate::vec::Vec2;
|
||||
use self::pancurses::mmask_t;
|
||||
use super::split_i32;
|
||||
|
||||
// Use AHash instead of the slower SipHash
|
||||
type HashMap<K, V> = std::collections::HashMap<K, V, ahash::ABuildHasher>;
|
||||
|
||||
/// Backend using pancurses.
|
||||
pub struct Backend {
|
||||
// Used
|
||||
@ -75,7 +77,7 @@ impl Backend {
|
||||
|
||||
let c = Backend {
|
||||
current_style: Cell::new(ColorPair::from_256colors(0, 0)),
|
||||
pairs: RefCell::new(HashMap::new()),
|
||||
pairs: RefCell::new(HashMap::default()),
|
||||
key_codes: initialize_keymap(),
|
||||
last_mouse_button: None,
|
||||
input_buffer: None,
|
||||
@ -530,7 +532,7 @@ fn get_mouse_button(bare_event: mmask_t) -> MouseButton {
|
||||
}
|
||||
|
||||
fn initialize_keymap() -> HashMap<i32, Event> {
|
||||
let mut map = HashMap::new();
|
||||
let mut map = HashMap::default();
|
||||
|
||||
super::fill_key_codes(&mut map, pancurses::keyname);
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
use hashbrown::HashMap;
|
||||
use std::any::Any;
|
||||
use std::num::NonZeroU32;
|
||||
use std::path::Path;
|
||||
@ -20,6 +19,9 @@ static DEBUG_VIEW_ID: &str = "_cursive_debug_view";
|
||||
// How long we wait between two empty input polls
|
||||
const INPUT_POLL_DELAY_MS: u64 = 30;
|
||||
|
||||
// Use AHash instead of the slower SipHash
|
||||
type HashMap<K, V> = std::collections::HashMap<K, V, ahash::ABuildHasher>;
|
||||
|
||||
/// Central part of the cursive library.
|
||||
///
|
||||
/// It initializes ncurses on creation and cleans up on drop.
|
||||
@ -137,7 +139,7 @@ impl Cursive {
|
||||
theme,
|
||||
screens: vec![views::StackView::new()],
|
||||
last_sizes: Vec::new(),
|
||||
global_callbacks: HashMap::new(),
|
||||
global_callbacks: HashMap::default(),
|
||||
menubar: views::Menubar::new(),
|
||||
active_screen: 0,
|
||||
running: true,
|
||||
|
@ -3,9 +3,11 @@ use enum_map::{enum_map, Enum, EnumMap};
|
||||
use log::warn;
|
||||
use toml;
|
||||
|
||||
use hashbrown::HashMap;
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
// Use AHash instead of the slower SipHash
|
||||
type HashMap<K, V> = std::collections::HashMap<K, V, ahash::ABuildHasher>;
|
||||
|
||||
/// Color configuration for the application.
|
||||
///
|
||||
/// Assign each color role an actual color.
|
||||
@ -165,7 +167,7 @@ impl Default for Palette {
|
||||
Highlight => Dark(Red),
|
||||
HighlightInactive => Dark(Blue),
|
||||
},
|
||||
custom: HashMap::new(),
|
||||
custom: HashMap::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user