From 816c94049aa09fc82390e2b49992f303a9a93461 Mon Sep 17 00:00:00 2001 From: Tomasz Golinski Date: Mon, 25 Sep 2023 18:35:05 +0200 Subject: [PATCH] Add some constexpr to some functions --- common.cpp | 7 +------ common.h | 9 ++++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/common.cpp b/common.cpp index 4dd1bb5..8a02013 100644 --- a/common.cpp +++ b/common.cpp @@ -5,11 +5,6 @@ #include #include #include -#include - -float degtorad(float x) { - return x * M_PI / 180; -} void htmlencode(std::string& data) { std::string tmp; @@ -41,7 +36,7 @@ void htmlencode(std::string& data) { data.swap(tmp); } -static std::string string_mangle(const std::string& str) { +constexpr static std::string string_mangle(const std::string& str) { std::string tmp; tmp.reserve(str.size()); diff --git a/common.h b/common.h index 3088d02..cf6e3f5 100644 --- a/common.h +++ b/common.h @@ -1,13 +1,11 @@ #pragma once -// #include "cache.h" -// #include "powertrail.h" - #include #include #include #include #include +#include class Cache; @@ -68,7 +66,8 @@ public: explicit Position(std::string loc); }; - float cache_distance(const Cache& a, const Cache& b); -float degtorad(float x); +constexpr float degtorad(float x) { + return x * M_PI / 180; +}