diff --git a/CMakeLists.txt b/CMakeLists.txt index 02ad17654..f85b1e50e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,7 +106,7 @@ set(FISH_SRCS src/expand.cpp src/fallback.cpp src/fd_monitor.cpp src/fish_version.cpp src/flog.cpp src/function.cpp src/future_feature_flags.cpp src/highlight.cpp src/history.cpp src/history_file.cpp src/input.cpp src/input_common.cpp - src/intern.cpp src/io.cpp src/iothread.cpp src/job_group.cpp src/kill.cpp + src/io.cpp src/iothread.cpp src/job_group.cpp src/kill.cpp src/null_terminated_array.cpp src/operation_context.cpp src/output.cpp src/pager.cpp src/parse_execution.cpp src/parse_tree.cpp src/parse_util.cpp src/parser.cpp src/parser_keywords.cpp src/path.cpp src/postfork.cpp diff --git a/src/builtin.cpp b/src/builtin.cpp index b30bac0d9..0a9836a9b 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -71,7 +71,6 @@ #include "exec.h" #include "fallback.h" // IWYU pragma: keep #include "flog.h" -#include "intern.h" #include "io.h" #include "parse_constants.h" #include "parse_util.h" @@ -430,13 +429,6 @@ static const builtin_data_t *builtin_lookup(const wcstring &name) { return get_by_sorted_name(name.c_str(), builtin_datas); } -/// Initialize builtin data. -void builtin_init() { - for (const auto &builtin_data : builtin_datas) { - intern_static(builtin_data.name); - } -} - /// Is there a builtin command with the given name? bool builtin_exists(const wcstring &cmd) { return static_cast(builtin_lookup(cmd)); } diff --git a/src/builtin.h b/src/builtin.h index e8aff3b68..4b5e8b094 100644 --- a/src/builtin.h +++ b/src/builtin.h @@ -78,7 +78,6 @@ struct builtin_data_t { /// The send stuff to foreground message. #define FG_MSG _(L"Send job %d (%ls) to foreground\n") -void builtin_init(); bool builtin_exists(const wcstring &cmd); proc_status_t builtin_run(parser_t &parser, const wcstring_list_t &argv, io_streams_t &streams); diff --git a/src/builtins/source.cpp b/src/builtins/source.cpp index 2cd81fd5f..8ecb937be 100644 --- a/src/builtins/source.cpp +++ b/src/builtins/source.cpp @@ -13,7 +13,6 @@ #include "../common.h" #include "../env.h" #include "../fallback.h" // IWYU pragma: keep -#include "../intern.h" #include "../io.h" #include "../parser.h" #include "../proc.h" diff --git a/src/fish.cpp b/src/fish.cpp index 5c0cef642..b06ca5398 100644 --- a/src/fish.cpp +++ b/src/fish.cpp @@ -48,7 +48,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include "function.h" #include "future_feature_flags.h" #include "history.h" -#include "intern.h" #include "io.h" #include "parse_util.h" #include "parser.h" @@ -502,7 +501,6 @@ int main(int argc, char **argv) { } mutable_fish_features().set_from_string(opts.features); proc_init(); - builtin_init(); misc_init(); reader_init(); diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index f80b610e6..42331bcb2 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -7083,7 +7083,6 @@ int main(int argc, char **argv) { set_main_thread(); setup_fork_guards(); proc_init(); - builtin_init(); env_init(); misc_init(); reader_init(); diff --git a/src/function.cpp b/src/function.cpp index 07ad6bb96..22c967a46 100644 --- a/src/function.cpp +++ b/src/function.cpp @@ -25,7 +25,6 @@ #include "exec.h" #include "fallback.h" // IWYU pragma: keep #include "function.h" -#include "intern.h" #include "parser.h" #include "parser_keywords.h" #include "reader.h" diff --git a/src/intern.cpp b/src/intern.cpp deleted file mode 100644 index e2bfb0f8a..000000000 --- a/src/intern.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Library for pooling common strings. -#include "config.h" // IWYU pragma: keep - -#include "intern.h" - -#include - -#include -#include -#include -#include - -#include "common.h" -#include "fallback.h" // IWYU pragma: keep - -static bool string_less_than_string(const wchar_t *a, const wchar_t *b) { - return std::wcscmp(a, b) < 0; -} - -/// The table of intern'd strings. -owning_lock> string_table; - -static const wchar_t *intern_with_dup(const wchar_t *in, bool dup) { - if (!in) return nullptr; - - auto table = string_table.acquire(); - - const wchar_t *result; - auto iter = std::lower_bound(table->begin(), table->end(), in, string_less_than_string); - if (iter != table->end() && std::wcscmp(*iter, in) == 0) { - result = *iter; - } else { - result = dup ? wcsdup(in) : in; - table->insert(iter, result); - } - return result; -} - -const wchar_t *intern(const wchar_t *in) { return intern_with_dup(in, true); } - -const wchar_t *intern_static(const wchar_t *in) { return intern_with_dup(in, false); } diff --git a/src/intern.h b/src/intern.h deleted file mode 100644 index cba471451..000000000 --- a/src/intern.h +++ /dev/null @@ -1,17 +0,0 @@ -// Library for pooling common strings. -#ifndef FISH_INTERN_H -#define FISH_INTERN_H - -/// Return an identical copy of the specified string from a pool of unique strings. If the string -/// was not in the pool, add a copy. -/// -/// \param in the string to return an interned copy of. -const wchar_t *intern(const wchar_t *in); - -/// Insert the specified string literal into the pool of unique strings. The string will not first -/// be copied, and it will not be free'd on exit. -/// -/// \param in the string to add to the interned pool -const wchar_t *intern_static(const wchar_t *in); - -#endif diff --git a/src/parser.cpp b/src/parser.cpp index e9843ff69..54fbe5cc6 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -19,7 +19,6 @@ #include "fallback.h" // IWYU pragma: keep #include "flog.h" #include "function.h" -#include "intern.h" #include "job_group.h" #include "parse_constants.h" #include "parse_execution.h" diff --git a/src/reader.cpp b/src/reader.cpp index a49806faf..36c757d35 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -61,7 +61,6 @@ #include "history.h" #include "input.h" #include "input_common.h" -#include "intern.h" #include "io.h" #include "iothread.h" #include "kill.h"