mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-07-02 00:51:15 -03:00
Cleanup common.h
Remove a bunch of headers, simplify lots of code, migrate it into .cpp files. Debug build time improves by ~3 seconds on my Mac.
This commit is contained in:
@@ -171,6 +171,10 @@ struct equal_to<completion_entry_t> {
|
||||
typedef std::unordered_set<completion_entry_t> completion_entry_set_t;
|
||||
static owning_lock<completion_entry_set_t> s_completion_set;
|
||||
|
||||
/// Completion "wrapper" support. The map goes from wrapping-command to wrapped-command-list.
|
||||
using wrapper_map_t = std::unordered_map<wcstring, wcstring_list_t>;
|
||||
static owning_lock<wrapper_map_t> wrapper_map;
|
||||
|
||||
/// Comparison function to sort completions by their order field.
|
||||
static bool compare_completions_by_order(const completion_entry_t &p1,
|
||||
const completion_entry_t &p2) {
|
||||
@@ -1637,22 +1641,20 @@ wcstring complete_print() {
|
||||
}
|
||||
}
|
||||
|
||||
// Append wraps. This is a wonky interface where even values are the commands, and odd values
|
||||
// are the targets that they wrap.
|
||||
auto wrap_pairs = complete_get_wrap_pairs();
|
||||
for (const auto &entry : wrap_pairs) {
|
||||
append_format(out, L"complete --command %ls --wraps %ls\n", std::get<0>(entry).c_str(),
|
||||
std::get<1>(entry).c_str());
|
||||
// Append wraps.
|
||||
auto locked_wrappers = wrapper_map.acquire();
|
||||
for (const auto &entry : *locked_wrappers) {
|
||||
const wcstring &src = entry.first;
|
||||
for (const wcstring &target : entry.second) {
|
||||
append_format(out, L"complete --command %ls --wraps %ls\n", src.c_str(),
|
||||
target.c_str());
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void complete_invalidate_path() { completion_autoloader.invalidate(); }
|
||||
|
||||
/// Completion "wrapper" support. The map goes from wrapping-command to wrapped-command-list.
|
||||
using wrapper_map_t = std::unordered_map<wcstring, wcstring_list_t>;
|
||||
static owning_lock<wrapper_map_t> wrapper_map;
|
||||
|
||||
/// Add a new target that wraps a command. Example: __fish_XYZ (function) wraps XYZ (target).
|
||||
bool complete_add_wrapper(const wcstring &command, const wcstring &new_target) {
|
||||
if (command.empty() || new_target.empty()) {
|
||||
@@ -1704,8 +1706,3 @@ wcstring_list_t complete_get_wrap_targets(const wcstring &command) {
|
||||
if (iter == wraps.end()) return {};
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
tuple_list<wcstring, wcstring> complete_get_wrap_pairs() {
|
||||
auto locked_map = wrapper_map.acquire();
|
||||
return flatten(*locked_map);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user