mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-27 08:10:24 +01:00
perf(backend): pre-compile regexp
This commit is contained in:
parent
6173cebdca
commit
9b5b3a4d1b
1 changed files with 5 additions and 2 deletions
|
@ -54,6 +54,9 @@ type DecodedReaction = {
|
||||||
host?: string | null;
|
host?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isCustomEmojiRegexp = /^:([\w+-]+)(?:@\.)?:$/;
|
||||||
|
const decodeCustomEmojiRegexp = /^:([\w+-]+)(?:@([\w.-]+))?:$/;
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ReactionService {
|
export class ReactionService {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -306,7 +309,7 @@ export class ReactionService {
|
||||||
return unicode.match('\u200d') ? unicode : unicode.replace(/\ufe0f/g, '');
|
return unicode.match('\u200d') ? unicode : unicode.replace(/\ufe0f/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
const custom = reaction.match(/^:([\w+-]+)(?:@\.)?:$/);
|
const custom = reaction.match(isCustomEmojiRegexp);
|
||||||
if (custom) {
|
if (custom) {
|
||||||
const name = custom[1];
|
const name = custom[1];
|
||||||
const emoji = reacterHost == null
|
const emoji = reacterHost == null
|
||||||
|
@ -324,7 +327,7 @@ export class ReactionService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public decodeReaction(str: string): DecodedReaction {
|
public decodeReaction(str: string): DecodedReaction {
|
||||||
const custom = str.match(/^:([\w+-]+)(?:@([\w.-]+))?:$/);
|
const custom = str.match(decodeCustomEmojiRegexp);
|
||||||
|
|
||||||
if (custom) {
|
if (custom) {
|
||||||
const name = custom[1];
|
const name = custom[1];
|
||||||
|
|
Loading…
Reference in a new issue