[Optimization] Handle channel name filter checks in memory (#2767)

* Handle channel name filter checks in memory

With this commit, name filters are loaded into memory when the server loads and new channels are compared against these memory values VS hitting the database each time.

* Minor formatting tweaks
This commit is contained in:
Vayle
2023-01-19 22:23:11 -05:00
committed by GitHub
parent 3424ae2dde
commit ba5b901c16
4 changed files with 50 additions and 6 deletions
+24 -1
View File
@@ -803,9 +803,19 @@ bool ChatChannelList::IsOnChannelBlockList(const std::string& channel_name) {
}
// Check if channel_name is already in the BlockedChannelNames vector
return Strings::Contains(ChatChannelList::GetBlockedChannelNames(), channel_name);
return Strings::Contains(GetBlockedChannelNames(), channel_name);
}
bool ChatChannelList::IsOnFilteredNameList(const std::string& name) {
if (name.empty()) {
return false;
}
// Check if name is already in the filtered name vector
return Strings::Contains(GetFilteredNames(), name);
}
void ChatChannelList::AddToChannelBlockList(const std::string& channel_name) {
if (channel_name.empty()) {
return;
@@ -822,6 +832,19 @@ void ChatChannelList::AddToChannelBlockList(const std::string& channel_name) {
}
}
void ChatChannelList::AddToFilteredNames(const std::string& name) {
if (name.empty()) {
return;
}
// Add name to the filtered names vector if it is not already present
if (!Strings::Contains(ChatChannelList::GetFilteredNames(), name)) {
auto filtered_names = GetFilteredNames(); // Get current filter name list
filtered_names.push_back(name); // Add new name to local filtered names list
SetFilteredNameList(filtered_names); // Set filtered names list to match local filtered names list
}
}
void ServerToClient45SayLink(std::string& clientSayLink, const std::string& serverSayLink) {
if (serverSayLink.find('\x12') == std::string::npos) {
clientSayLink = serverSayLink;