From a230e9650652bc7116ba4ff539282d6dc7014881 Mon Sep 17 00:00:00 2001 From: Reinder Feenstra Date: Fri, 3 Dec 2021 23:36:22 +0100 Subject: [PATCH] moved rtrim() to rtrim.hpp, removed duplicate startsWith() --- server/src/hardware/protocol/dccplusplus/kernel.cpp | 2 +- server/src/utils/{string.hpp => rtrim.hpp} | 13 ++++--------- server/src/world/worldloader.cpp | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) rename server/src/utils/{string.hpp => rtrim.hpp} (79%) diff --git a/server/src/hardware/protocol/dccplusplus/kernel.cpp b/server/src/hardware/protocol/dccplusplus/kernel.cpp index be4818a3..1df94ac6 100644 --- a/server/src/hardware/protocol/dccplusplus/kernel.cpp +++ b/server/src/hardware/protocol/dccplusplus/kernel.cpp @@ -25,7 +25,7 @@ #include "../../decoder/decoder.hpp" #include "../../decoder/decoderchangeflags.hpp" #include "../../../utils/setthreadname.hpp" -#include "../../../utils/string.hpp" +#include "../../../utils/rtrim.hpp" #include "../../../core/eventloop.hpp" #include "../../../log/log.hpp" diff --git a/server/src/utils/string.hpp b/server/src/utils/rtrim.hpp similarity index 79% rename from server/src/utils/string.hpp rename to server/src/utils/rtrim.hpp index 96f20a11..08990edf 100644 --- a/server/src/utils/string.hpp +++ b/server/src/utils/rtrim.hpp @@ -1,9 +1,9 @@ /** - * server/src/utils/string.hpp + * server/src/utils/rtrim.hpp * * This file is part of the traintastic source code. * - * Copyright (C) 2019-2020 Reinder Feenstra + * Copyright (C) 2021 Reinder Feenstra * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,16 +20,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef TRAINTASTIC_SERVER_UTILS_STRING_HPP -#define TRAINTASTIC_SERVER_UTILS_STRING_HPP +#ifndef TRAINTASTIC_SERVER_UTILS_RTRIM_HPP +#define TRAINTASTIC_SERVER_UTILS_RTRIM_HPP #include -constexpr bool startsWith(std::string_view s, std::string_view prefix) -{ - return s.rfind(prefix, 0) == 0; -} - constexpr std::string_view rtrim(std::string_view s, char c) { if(s.empty()) diff --git a/server/src/world/worldloader.cpp b/server/src/world/worldloader.cpp index b919b8fe..895186d5 100644 --- a/server/src/world/worldloader.cpp +++ b/server/src/world/worldloader.cpp @@ -26,7 +26,7 @@ #include #include #include "world.hpp" -#include "../utils/string.hpp" +#include "../utils/startswith.hpp" #include "ctwreader.hpp" #include "../board/board.hpp"