revert: move to ahash (#9464)

This PR reverts https://github.com/nushell/nushell/pull/9391

We try not to revert PRs like this, though after discussion with the
Nushell team, we decided to revert this one.

The main reason is that Nushell, as a codebase, isn't ready for these
kinds of optimisations. It's in the part of the development cycle where
our main focus should be on improving the algorithms inside of Nushell
itself. Once we have matured our algorithms, then we can look for
opportunities to switch out technologies we're using for alternate
forms.

Much of Nushell still has lots of opportunities for tuning the codebase,
paying down technical debt, and making the codebase generally cleaner
and more robust. This should be the focus. Performance improvements
should flow out of that work.

Said another, optimisation that isn't part of tuning the codebase is
premature at this stage. We need to focus on doing the hard work of
making the engine, parser, etc better.

# User-Facing Changes

Reverts the HashMap -> ahash change.

cc @FilipAndersson245
This commit is contained in:
JT
2023-06-18 15:27:57 +12:00
committed by GitHub
parent fc1ffe487a
commit 6c730def4b
68 changed files with 53 additions and 81 deletions

View File

@ -28,7 +28,6 @@ nu-utils = { path = "../nu-utils", version = "0.81.1" }
nu-ansi-term = "0.47.0"
alphanumeric-sort = "1.5"
ahash = "0.8.3"
atty = "0.2"
base64 = "0.21"
byteorder = "1.4"

View File

@ -159,8 +159,8 @@ impl PartialEq for HashableValue {
#[cfg(test)]
mod test {
use super::*;
use ahash::{HashMap, HashMapExt, HashSet, HashSetExt};
use nu_protocol::ast::{CellPath, PathMember};
use std::collections::{HashMap, HashSet};
#[test]
fn from_value() {

View File

@ -1,5 +1,4 @@
use super::hashable_value::HashableValue;
use ahash::{HashMap, HashMapExt};
use itertools::Itertools;
use nu_engine::CallExt;
use nu_protocol::ast::Call;
@ -8,6 +7,7 @@ use nu_protocol::{
Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape,
Type, Value,
};
use std::collections::HashMap;
use std::iter;
#[derive(Clone)]

View File

@ -1,4 +1,4 @@
use ahash::HashMap;
use std::collections::HashMap;
/// Return map of <deprecated_command_name, new_command_name>
/// This covers simple deprecated commands nicely, but it's not great for deprecating

View File

@ -1,4 +1,4 @@
use ahash::HashMap;
use std::collections::HashMap;
use std::path::PathBuf;
use nu_protocol::{

View File

@ -1,4 +1,4 @@
use ahash::{HashMap, HashMapExt};
use std::collections::HashMap;
use nu_engine::{eval_block, CallExt};
use nu_protocol::{

View File

@ -14,7 +14,6 @@ mod test_examples {
SplitRow, Str, StrJoin, StrLength, StrReplace, Update, Url, Values, Wrap,
};
use crate::{Each, To};
use ahash::{HashSet, HashSetExt};
use nu_cmd_lang::example_support::{
check_all_signature_input_output_types_entries_have_examples,
check_example_evaluates_to_expected_output,
@ -25,6 +24,7 @@ mod test_examples {
engine::{Command, EngineState, StateWorkingSet},
Type,
};
use std::collections::HashSet;
pub fn test_examples(cmd: impl Command + 'static) {
let examples = cmd.examples();

View File

@ -1,4 +1,4 @@
use ahash::{HashMap, HashMapExt};
use std::collections::HashMap;
#[cfg(all(
feature = "trash-support",
not(target_os = "android"),

View File

@ -1,4 +1,3 @@
use ahash::{HashMap, HashMapExt, HashSet, HashSetExt};
use nu_engine::CallExt;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
@ -6,6 +5,7 @@ use nu_protocol::{
Config, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value,
};
use std::cmp::max;
use std::collections::{HashMap, HashSet};
#[derive(Clone)]
pub struct Join;

View File

@ -1,4 +1,3 @@
use ahash::{HashSet, HashSetExt};
use nu_engine::CallExt;
use nu_protocol::ast::{Call, CellPath, PathMember};
use nu_protocol::engine::{Command, EngineState, Stack};
@ -6,6 +5,7 @@ use nu_protocol::{
Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData,
PipelineIterator, ShellError, Signature, Span, SyntaxShape, Type, Value,
};
use std::collections::HashSet;
#[derive(Clone)]
pub struct Select;

View File

@ -1,5 +1,4 @@
use crate::formats::value_to_string;
use ahash::{HashMap, HashMapExt};
use itertools::Itertools;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
@ -8,6 +7,7 @@ use nu_protocol::{
Span, Type, Value,
};
use std::collections::hash_map::IntoIter;
use std::collections::HashMap;
#[derive(Clone)]
pub struct Uniq;

View File

@ -1,4 +1,3 @@
use ahash::HashSet;
use nu_engine::{eval_block, CallExt};
use nu_protocol::ast::{Block, Call};
use nu_protocol::engine::{Closure, Command, EngineState, Stack};
@ -6,6 +5,7 @@ use nu_protocol::{
Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData,
PipelineIterator, ShellError, Signature, Span, SyntaxShape, Type, Value,
};
use std::collections::HashSet;
use std::iter::FromIterator;
#[derive(Clone)]

View File

@ -1,5 +1,4 @@
use crate::formats::to::delimited::merge_descriptors;
use ahash::{HashMap, HashMapExt};
use fancy_regex::Regex;
use nu_engine::CallExt;
use nu_protocol::ast::Call;
@ -10,6 +9,7 @@ use nu_protocol::{
};
use rust_embed::RustEmbed;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::error::Error;
use std::fmt::Write;

View File

@ -1,9 +1,9 @@
use crate::math::utils::run_with_function;
use ahash::{HashMap, HashMapExt};
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value};
use std::cmp::Ordering;
use std::collections::HashMap;
#[derive(Clone)]
pub struct SubCommand;

View File

@ -9,7 +9,7 @@ use nu_protocol::{
};
use ureq::{Error, ErrorKind, Request, Response};
use ahash::{HashMap, HashMapExt};
use std::collections::HashMap;
use std::io::BufReader;
use std::path::PathBuf;
use std::str::FromStr;

View File

@ -1,4 +1,4 @@
use ahash::HashMap;
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use nu_engine::CallExt;

View File

@ -1,4 +1,3 @@
use ahash::{HashMap, HashMapExt};
use nu_ansi_term::*;
use nu_engine::CallExt;
use nu_protocol::engine::{EngineState, Stack};
@ -7,6 +6,7 @@ use nu_protocol::{
PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value,
};
use once_cell::sync::Lazy;
use std::collections::HashMap;
#[derive(Clone)]
pub struct AnsiCommand;

View File

@ -1,5 +1,4 @@
use crate::hook::eval_hook;
use ahash::HashMap;
use nu_engine::env_to_strings;
use nu_engine::CallExt;
use nu_protocol::{
@ -12,6 +11,7 @@ use nu_protocol::{
use nu_system::ForegroundProcess;
use os_pipe::PipeReader;
use pathdiff::diff_paths;
use std::collections::HashMap;
use std::io::{BufRead, BufReader, Read, Write};
use std::path::{Path, PathBuf};
use std::process::{Command as CommandSys, Stdio};

View File

@ -1,6 +1,6 @@
use ahash::HashMap;
use nu_protocol::{ShellError, Span};
use once_cell::sync::Lazy;
use std::collections::HashMap;
use std::path::Path;
// Attribution: Thanks exa. Most of this file is taken from around here