[Code] Remove Regex Compile Bloat (#4947)

This commit is contained in:
Chris Miles 2025-06-22 02:08:15 -05:00 committed by GitHub
parent 3e6a3e2168
commit e846bb86b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 10 deletions

View File

@ -4,7 +4,6 @@
#include <string>
#include "../types.h"
#include "../http/httplib.h"
#include "../repositories/player_event_logs_repository.h"
#include "../events/player_events.h"

View File

@ -1,6 +1,8 @@
module should-release
go 1.18
go 1.23.0
toolchain go1.23.5
require (
github.com/google/go-github/v41 v41.0.0

View File

@ -1,4 +1,3 @@
#include "../../common/http/httplib.h"
#include "../../common/eqemu_logsys.h"
#include "../../common/platform.h"
#include "../../zone.h"

View File

@ -1,5 +1,3 @@
#include <regex>
#include "dialogue_window.h"
void DialogueWindow::Render(Client *c, std::string markdown)
@ -529,12 +527,19 @@ std::string DialogueWindow::CenterMessage(std::string message)
return std::string();
}
auto cleaned_message = message;
std::string cleaned_message;
cleaned_message.reserve(message.size());
std::regex tags("<[^>]*>");
if (std::regex_search(cleaned_message, tags)) {
std::regex_replace(cleaned_message, tags, cleaned_message);
// Strip HTML-like tags
bool in_tag = false;
for (char c : 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();