[Code] Remove Regex Compile Bloat

This commit is contained in:
Chris Miles
2025-06-21 20:10:18 -05:00
parent 1be7e56b86
commit 2353d3352b
4 changed files with 15 additions and 10 deletions
-1
View File
@@ -4,7 +4,6 @@
#include <string> #include <string>
#include "../types.h" #include "../types.h"
#include "../http/httplib.h"
#include "../repositories/player_event_logs_repository.h" #include "../repositories/player_event_logs_repository.h"
#include "../events/player_events.h" #include "../events/player_events.h"
+3 -1
View File
@@ -1,6 +1,8 @@
module should-release module should-release
go 1.18 go 1.23.0
toolchain go1.23.5
require ( require (
github.com/google/go-github/v41 v41.0.0 github.com/google/go-github/v41 v41.0.0
@@ -1,4 +1,3 @@
#include "../../common/http/httplib.h"
#include "../../common/eqemu_logsys.h" #include "../../common/eqemu_logsys.h"
#include "../../common/platform.h" #include "../../common/platform.h"
#include "../../zone.h" #include "../../zone.h"
+12 -7
View File
@@ -1,5 +1,3 @@
#include <regex>
#include "dialogue_window.h" #include "dialogue_window.h"
void DialogueWindow::Render(Client *c, std::string markdown) void DialogueWindow::Render(Client *c, std::string markdown)
@@ -529,12 +527,19 @@ std::string DialogueWindow::CenterMessage(std::string message)
return std::string(); return std::string();
} }
auto cleaned_message = message; std::string cleaned_message;
cleaned_message.reserve(message.size());
std::regex tags("<[^>]*>"); // Strip HTML-like tags
bool in_tag = false;
if (std::regex_search(cleaned_message, tags)) { for (char c : message) {
std::regex_replace(cleaned_message, tags, cleaned_message); if (c == '<') {
in_tag = true;
} else if (c == '>' && in_tag) {
in_tag = false;
} else if (!in_tag) {
cleaned_message += c;
}
} }
auto message_len = cleaned_message.length(); auto message_len = cleaned_message.length();