summaryrefslogtreecommitdiff
path: root/packages/backend/src/core
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-05-18 18:18:25 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-05-18 18:18:25 +0900
commit9b5b3a4d1b887ff29ce79f1639886f3c69def54f (patch)
tree5e09dd447e0df8aaf80629a33bcda8eeb5991f35 /packages/backend/src/core
parentci: remove deprecated notifications (diff)
downloadmisskey-9b5b3a4d1b887ff29ce79f1639886f3c69def54f.tar.gz
misskey-9b5b3a4d1b887ff29ce79f1639886f3c69def54f.tar.bz2
misskey-9b5b3a4d1b887ff29ce79f1639886f3c69def54f.zip
perf(backend): pre-compile regexp
Diffstat (limited to 'packages/backend/src/core')
-rw-r--r--packages/backend/src/core/ReactionService.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/packages/backend/src/core/ReactionService.ts b/packages/backend/src/core/ReactionService.ts
index a274b19e4b..2184cfeb41 100644
--- a/packages/backend/src/core/ReactionService.ts
+++ b/packages/backend/src/core/ReactionService.ts
@@ -54,6 +54,9 @@ type DecodedReaction = {
host?: string | null;
};
+const isCustomEmojiRegexp = /^:([\w+-]+)(?:@\.)?:$/;
+const decodeCustomEmojiRegexp = /^:([\w+-]+)(?:@([\w.-]+))?:$/;
+
@Injectable()
export class ReactionService {
constructor(
@@ -306,7 +309,7 @@ export class ReactionService {
return unicode.match('\u200d') ? unicode : unicode.replace(/\ufe0f/g, '');
}
- const custom = reaction.match(/^:([\w+-]+)(?:@\.)?:$/);
+ const custom = reaction.match(isCustomEmojiRegexp);
if (custom) {
const name = custom[1];
const emoji = reacterHost == null
@@ -324,7 +327,7 @@ export class ReactionService {
@bindThis
public decodeReaction(str: string): DecodedReaction {
- const custom = str.match(/^:([\w+-]+)(?:@([\w.-]+))?:$/);
+ const custom = str.match(decodeCustomEmojiRegexp);
if (custom) {
const name = custom[1];