Skip to content

Commit 32d5382

Browse files
christolisdevloves
andcommitted
perf: remove pattern compilation for each call
Co-authored-by: Devansh Tiwari <65783463+devloves@users.noreply.github.com>
1 parent dcc3ab3 commit 32d5382

File tree

2 files changed

+130
-2
lines changed

2 files changed

+130
-2
lines changed

application/config-rss.json

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
{
2+
"token": "MTE2MDMzNzk5NTY5NDYxMjU4MA.G0BGGy.04r98mu6HP7eTCs2kMd0qcvcyiH5ErrJ1wZv1M",
3+
"githubApiKey": "<your_github_personall_access_token>",
4+
"databasePath": "local-database.db",
5+
"projectWebsite": "https://github.com/Together-Java/TJ-Bot",
6+
"discordGuildInvite": "https://discord.com/invite/XXFUXzK",
7+
"modAuditLogChannelPattern": "mod-audit-log",
8+
"modMailChannelPattern": "modmail",
9+
"mutedRolePattern": "Muted",
10+
"heavyModerationRolePattern": "Moderator",
11+
"softModerationRolePattern": "Moderator|Community Ambassador",
12+
"tagManageRolePattern": "Moderator|Community Ambassador|Top Helpers .+",
13+
"excludeCodeAutoDetectionRolePattern": "Top Helpers .+|Moderator|Community Ambassador|Expert",
14+
"suggestions": {
15+
"channelPattern": "tj-suggestions",
16+
"upVoteEmoteName": "peepo_yes",
17+
"downVoteEmoteName": "peepo_no"
18+
},
19+
"quarantinedRolePattern": "Quarantined",
20+
"scamBlocker": {
21+
"mode": "AUTO_DELETE_BUT_APPROVE_QUARANTINE",
22+
"reportChannelPattern": "commands",
23+
"suspiciousKeywords": ["nitro", "boob", "sexy", "sexi", "esex"],
24+
"hostWhitelist": ["discord.com", "discord.gg", "discord.media", "discordapp.com", "discordapp.net", "discordstatus.com"],
25+
"hostBlacklist": ["bit.ly"],
26+
"suspiciousHostKeywords": ["discord", "nitro", "premium"],
27+
"isHostSimilarToKeywordDistanceThreshold": 2
28+
},
29+
"wolframAlphaAppId": "79J52T-6239TVXHR7",
30+
"helpSystem": {
31+
"helpForumPattern": "questions",
32+
"categories": [
33+
"Java",
34+
"Frameworks",
35+
"JavaFX|Swing",
36+
"IDE",
37+
"Build Tools",
38+
"Database",
39+
"Android",
40+
"C|C++",
41+
"Algorithms",
42+
"Math",
43+
"Architecture",
44+
"Code Review",
45+
"Together Java Bot",
46+
"Other"
47+
],
48+
"categoryRoleSuffix": " - Helper"
49+
},
50+
"mediaOnlyChannelPattern": "memes",
51+
"blacklistedFileExtension": [
52+
"application",
53+
"bat",
54+
"cmd",
55+
"com",
56+
"cpl",
57+
"exe",
58+
"gadget",
59+
"hta",
60+
"inf",
61+
"jse",
62+
"lnk",
63+
"msc",
64+
"msh",
65+
"msh1",
66+
"msh1xml",
67+
"msh2",
68+
"msh2xml",
69+
"mshxml",
70+
"msi",
71+
"msp",
72+
"pif",
73+
"ps1",
74+
"ps1xml",
75+
"ps2",
76+
"ps2xml",
77+
"psc1",
78+
"psc2",
79+
"scf",
80+
"scr",
81+
"vb",
82+
"vbe",
83+
"vbs",
84+
"ws",
85+
"wsc",
86+
"wsf",
87+
"wsh"
88+
],
89+
"githubReferencingEnabledChannelPattern": "server-suggestions|tjbot-discussion|modernjava-discussion",
90+
"githubRepositories": [403389278,587644974,601602394],
91+
"logInfoChannelWebhook": "https://discord.com/api/webhooks/1160343509979627590/39uT-cF3xWlXJr-KTK8Cx38FRifaplj7meq0AVbJo7o_Y1iJ7PZc7M-ZNxtgjxvm3Yh8",
92+
"logErrorChannelWebhook": "https://discord.com/api/webhooks/1160343463028592691/yFUpBitjJeI3h0ILVJoWOKEgpJJD5IR3VA90Dy7aUtFUz719PUYQrIe0WhCTZqWKYvhK",
93+
"openaiApiKey": "<check pins in #tjbot_discussion for the key>",
94+
"sourceCodeBaseUrl": "https://github.com/Together-Java/TJ-Bot/blob/master/application/src/main/java/",
95+
"jshell": {
96+
"baseUrl": "<put_jshell_rest_api_url_here>",
97+
"rateLimitWindowSeconds": 10,
98+
"rateLimitRequestsInWindow": 3
99+
},
100+
"helperPruneConfig": {
101+
"roleFullLimit": 100,
102+
"roleFullThreshold": 95,
103+
"pruneMemberAmount": 7,
104+
"inactivateAfterDays": 90,
105+
"recentlyJoinedDays": 4
106+
},
107+
"featureBlacklist": {
108+
"normal": [
109+
],
110+
"special": [
111+
]
112+
},
113+
"selectRolesChannelPattern": "select-your-roles",
114+
"javaNewsChannelPattern": "java-news-and-changes",
115+
"rssPollInterval": 10,
116+
"rssFeeds": [
117+
{
118+
"url": "https://lorem-rss.herokuapp.com/feed?unit=second&length=1",
119+
"targetChannelPattern": "java-news-and-changes",
120+
"dateFormatterPattern": "EEE, dd MMM yyyy HH:mm:ss zzz"
121+
},
122+
{
123+
"url": "https://justinpot.com/feed/",
124+
"targetChannelPattern": "resources",
125+
"dateFormatterPattern": "EEE, dd MMM yyyy HH:mm:ss Z"
126+
}
127+
]
128+
}

application/src/main/java/org/togetherjava/tjbot/features/basic/MemberCountDisplayRoutine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
public class MemberCountDisplayRoutine implements Routine {
1414
private final Predicate<String> wordsInCategory;
15-
15+
private static final Pattern baseNamePattern = Pattern.compile("(.+) - \\d+ Members");
1616

1717
public MemberCountDisplayRoutine(Config config) {
1818
wordsInCategory =
@@ -23,7 +23,7 @@ private void updateCategoryName(Category category) {
2323
int totalMemberCount = category.getGuild().getMemberCount();
2424
String baseName = category.getName();
2525
if (baseName.contains(" Members")) {
26-
baseName = Pattern.compile("(.+) - \\d+ Members").toString();
26+
baseName = baseNamePattern.toString();
2727
}
2828
category.getManager()
2929
.setName("%s - %d Members".formatted(baseName.trim(), totalMemberCount))

0 commit comments

Comments
 (0)