mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-18 12:01:16 -03:00
Squashed commit of the following:
commit 50f414a45d58fcab664ff662dd27befcfa0fdd95 Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net> Date: Sat Aug 19 13:43:35 2017 -0500 Converted file_id_t set to unordered_set with custom hash commit 83ef2dd7cc1bc3e4fdf0b2d3546d6811326cc3c9 Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net> Date: Sat Aug 19 13:43:14 2017 -0500 Converted remaining set<wcstring> to unordered_set<wcstring> commit 053da88f933f27505b3cf4810402e2a2be070203 Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net> Date: Sat Aug 19 13:29:21 2017 -0500 Switched function sets to unordered_set commit d469742a14ac99599022a9258cda8255178826b5 Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net> Date: Sat Aug 19 13:21:32 2017 -0500 Converted list of modified variables to an unordered set commit 5c06f866beeafb23878b1a932c7cd2558412c283 Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net> Date: Sat Aug 19 13:15:20 2017 -0500 Convert const_string_set_t to std::unordered_set As it is a readonly-list of raw character pointer strings (not wcstring), this necessitated the addition of a hashing function since the C++ standard library does not come with a char pointer hash function. To that end, a zlib-licensed [0] port of the excellent, lightweight XXHash family of 32- and 64-bit hashing algorithms in the form of a C++ header-only include library has been included. XXHash32/64 is pretty much universally the fastest hashing library for general purpose applications, and has been thoroughly vetted and is used in countless open source projects. The single-header version of this library makes it a lot simpler to include in the fish project, and the license compatibility with fish' GPLv2 and the zero-lib nature should make it an easy decision. std::unordered_set brings a massive speedup as compared to the default std::set, and the further use of the fast XXHash library to provide the string hashing should make all forms of string lookups in fish significantly faster (to a user-noticeable extent). 0: http://create.stephan-brumme.com/about.html commit 30d7710be8f0c23a4d42f7e713fcb7850f99036e Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net> Date: Sat Aug 19 12:29:39 2017 -0500 Using std::unordered_set for completions backing store While the completions shown to the user are sorted, their storage in memory does not need to be since they are re-sorted before they are shown in completions.cpp. commit 695e83331d7a60ba188e57f6ea0d9b6da54860c6 Author: Mahmoud Al-Qudsi <mqudsi@neosmart.net> Date: Sat Aug 19 12:06:53 2017 -0500 Updated is_loading to use unordered_set
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
@@ -33,7 +33,7 @@ typedef std::unordered_map<wcstring, function_info_t> function_map_t;
|
||||
static function_map_t loaded_functions;
|
||||
|
||||
/// Functions that shouldn't be autoloaded (anymore).
|
||||
static std::set<wcstring> function_tombstones;
|
||||
static std::unordered_set<wcstring> function_tombstones;
|
||||
|
||||
/// Lock for functions.
|
||||
static std::recursive_mutex functions_lock;
|
||||
@@ -76,7 +76,7 @@ static int load(const wcstring &name) {
|
||||
}
|
||||
|
||||
/// Insert a list of all dynamically loaded functions into the specified list.
|
||||
static void autoload_names(std::set<wcstring> &names, int get_hidden) {
|
||||
static void autoload_names(std::unordered_set<wcstring> &names, int get_hidden) {
|
||||
size_t i;
|
||||
|
||||
const env_var_t path_var = env_get(L"fish_function_path");
|
||||
@@ -282,13 +282,12 @@ bool function_copy(const wcstring &name, const wcstring &new_name) {
|
||||
}
|
||||
|
||||
wcstring_list_t function_get_names(int get_hidden) {
|
||||
std::set<wcstring> names;
|
||||
std::unordered_set<wcstring> names;
|
||||
scoped_rlock locker(functions_lock);
|
||||
autoload_names(names, get_hidden);
|
||||
|
||||
function_map_t::const_iterator iter;
|
||||
for (iter = loaded_functions.begin(); iter != loaded_functions.end(); ++iter) {
|
||||
const wcstring &name = iter->first;
|
||||
for (const auto &func : loaded_functions) {
|
||||
const wcstring &name = func.first;
|
||||
|
||||
// Maybe skip hidden.
|
||||
if (!get_hidden && (name.empty() || name.at(0) == L'_')) {
|
||||
|
||||
Reference in New Issue
Block a user