mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
[Code] Remove Regex Compile Bloat (#4947)
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user