mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 12:41:30 +00:00
[Code] Remove Regex Compile Bloat (#4947)
This commit is contained in:
parent
3e6a3e2168
commit
e846bb86b6
@ -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"
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
#include "../../common/http/httplib.h"
|
||||
#include "../../common/eqemu_logsys.h"
|
||||
#include "../../common/platform.h"
|
||||
#include "../../zone.h"
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user