From 1748dc7a3c18fef96ad7a23388b8c1c2321fac79 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Wed, 12 Mar 2025 17:29:24 +0000 Subject: [PATCH] Remove some unnecessary includes --- CMakeLists.txt | 1 - src/api/helpers/collections.h | 50 ----------------------- src/api/metadata/conditional_metadata.cpp | 4 -- src/api/metadata/file.cpp | 3 -- src/api/metadata/group.cpp | 2 - src/api/metadata/message.cpp | 4 +- src/api/metadata/message_content.cpp | 3 -- src/api/metadata/plugin_cleaning_data.cpp | 4 -- src/api/metadata/plugin_metadata.cpp | 24 +++++++++-- src/api/metadata/tag.cpp | 2 - src/api/sorting/undefined_group_error.cpp | 2 - 11 files changed, 21 insertions(+), 78 deletions(-) delete mode 100644 src/api/helpers/collections.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 00dfb580..8ad61563 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -279,7 +279,6 @@ set(LIBLOOT_SRC_API_H_FILES "${CMAKE_SOURCE_DIR}/src/api/sorting/plugin_sort.h" "${CMAKE_SOURCE_DIR}/src/api/sorting/plugin_graph.h" "${CMAKE_SOURCE_DIR}/src/api/sorting/plugin_sorting_data.h" - "${CMAKE_SOURCE_DIR}/src/api/helpers/collections.h" "${CMAKE_SOURCE_DIR}/src/api/helpers/crc.h" "${CMAKE_SOURCE_DIR}/src/api/helpers/logging.h" "${CMAKE_SOURCE_DIR}/src/api/helpers/text.h") diff --git a/src/api/helpers/collections.h b/src/api/helpers/collections.h deleted file mode 100644 index cea9d45c..00000000 --- a/src/api/helpers/collections.h +++ /dev/null @@ -1,50 +0,0 @@ -/* LOOT - - A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and - Fallout: New Vegas. - - Copyright (C) 2012-2016 WrinklyNinja - - This file is part of LOOT. - - LOOT is free software: you can redistribute - it and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. - - LOOT is distributed in the hope that it will - be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with LOOT. If not, see - . - */ - -#ifndef LOOT_API_HELPERS_COLLECTIONS -#define LOOT_API_HELPERS_COLLECTIONS - -#include - -namespace loot { -// Append second to first, skipping any elements that are already present in -// first. Although this is O(U * M), both input vectors are expected to be -// small (with tens of elements being an unusually large number). -template -std::vector mergeVectors(std::vector first, - const std::vector& second) { - const auto initialSizeOfFirst = first.size(); - for (const auto& element : second) { - const auto end = first.cbegin() + initialSizeOfFirst; - - if (std::find(first.cbegin(), end, element) == end) { - first.push_back(element); - } - } - - return first; -} -} - -#endif diff --git a/src/api/metadata/conditional_metadata.cpp b/src/api/metadata/conditional_metadata.cpp index 53fb452b..f778f686 100644 --- a/src/api/metadata/conditional_metadata.cpp +++ b/src/api/metadata/conditional_metadata.cpp @@ -24,10 +24,6 @@ #include "loot/metadata/conditional_metadata.h" -#include "api/game/game.h" -#include "api/helpers/logging.h" -#include "api/metadata/condition_evaluator.h" - namespace loot { ConditionalMetadata::ConditionalMetadata(const std::string& condition) : condition_(condition) {} diff --git a/src/api/metadata/file.cpp b/src/api/metadata/file.cpp index f6cb5039..132ec0fa 100644 --- a/src/api/metadata/file.cpp +++ b/src/api/metadata/file.cpp @@ -24,9 +24,6 @@ #include "loot/metadata/file.h" -#include "api/helpers/text.h" -#include "api/metadata/yaml/file.h" - namespace loot { File::File(const std::string& name, const std::string& display, diff --git a/src/api/metadata/group.cpp b/src/api/metadata/group.cpp index 135ff63c..a3117f16 100644 --- a/src/api/metadata/group.cpp +++ b/src/api/metadata/group.cpp @@ -24,8 +24,6 @@ #include "loot/metadata/group.h" -#include "api/metadata/yaml/group.h" - namespace loot { Group::Group(const std::string& name, const std::vector& afterGroups, diff --git a/src/api/metadata/message.cpp b/src/api/metadata/message.cpp index f43abfd3..ca152ab2 100644 --- a/src/api/metadata/message.cpp +++ b/src/api/metadata/message.cpp @@ -24,9 +24,7 @@ #include "loot/metadata/message.h" -#include - -#include "api/game/game.h" +#include namespace loot { Message::Message(const MessageType type, diff --git a/src/api/metadata/message_content.cpp b/src/api/metadata/message_content.cpp index 3c145e88..4458551a 100644 --- a/src/api/metadata/message_content.cpp +++ b/src/api/metadata/message_content.cpp @@ -24,9 +24,6 @@ #include "loot/metadata/message_content.h" -#include -#include - namespace loot { MessageContent::MessageContent(const std::string& text, const std::string& language) : diff --git a/src/api/metadata/plugin_cleaning_data.cpp b/src/api/metadata/plugin_cleaning_data.cpp index f9a3e880..8dc5d9fc 100644 --- a/src/api/metadata/plugin_cleaning_data.cpp +++ b/src/api/metadata/plugin_cleaning_data.cpp @@ -24,10 +24,6 @@ #include "loot/metadata/plugin_cleaning_data.h" -#include "api/game/game.h" -#include "api/helpers/crc.h" -#include "api/helpers/logging.h" - namespace loot { PluginCleaningData::PluginCleaningData(uint32_t crc, const std::string& utility) : diff --git a/src/api/metadata/plugin_metadata.cpp b/src/api/metadata/plugin_metadata.cpp index 21e63b09..9737d7d9 100644 --- a/src/api/metadata/plugin_metadata.cpp +++ b/src/api/metadata/plugin_metadata.cpp @@ -24,15 +24,31 @@ #include "loot/metadata/plugin_metadata.h" -#include #include -#include "api/game/game.h" -#include "api/helpers/collections.h" -#include "api/helpers/logging.h" #include "api/helpers/text.h" #include "api/metadata/yaml/plugin_metadata.h" +namespace { +// Append second to first, skipping any elements that are already present in +// first. Although this is O(U * M), both input vectors are expected to be +// small (with tens of elements being an unusually large number). +template +std::vector mergeVectors(std::vector first, + const std::vector& second) { + const auto initialSizeOfFirst = first.size(); + for (const auto& element : second) { + const auto end = first.cbegin() + initialSizeOfFirst; + + if (std::find(first.cbegin(), end, element) == end) { + first.push_back(element); + } + } + + return first; +} +} + namespace loot { PluginMetadata::PluginMetadata(const std::string& n) : name_(n) { // If the name passed ends in '.ghost', that should be trimmed. diff --git a/src/api/metadata/tag.cpp b/src/api/metadata/tag.cpp index ad056a72..1a551ad5 100644 --- a/src/api/metadata/tag.cpp +++ b/src/api/metadata/tag.cpp @@ -24,8 +24,6 @@ #include "loot/metadata/tag.h" -#include - namespace loot { Tag::Tag(const std::string& tag, const bool isAddition, diff --git a/src/api/sorting/undefined_group_error.cpp b/src/api/sorting/undefined_group_error.cpp index 293ac857..c955d1ce 100644 --- a/src/api/sorting/undefined_group_error.cpp +++ b/src/api/sorting/undefined_group_error.cpp @@ -23,8 +23,6 @@ */ #include "loot/exception/undefined_group_error.h" -#include "api/sorting/plugin_graph.h" - namespace loot { UndefinedGroupError::UndefinedGroupError(const std::string& groupName) : std::runtime_error("The group \"" + groupName + "\" does not exist"),