Skip to content

Commit 0c44bcb

Browse files
chrisbobbegnprice
authored andcommitted
emoji [nfc]: Make a helper's helper not mutate lists of emoji names
We're about to change _generatePopularCandidates so it looks up the emoji names in the ServerEmojiData, and we don't want to mutate ServerEmojiData. This isn't a hot codepath (it's called at most once per server-emoji-data fetch), so creating a new List isn't a problem.
1 parent f1b65bb commit 0c44bcb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/model/emoji.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,10 @@ class EmojiStoreImpl extends PerAccountStoreBase with EmojiStore {
221221

222222
static List<EmojiCandidate> _generatePopularCandidates() {
223223
EmojiCandidate candidate(String emojiCode, List<String> names) {
224-
final emojiName = names.removeAt(0);
224+
final [emojiName, ...aliases] = names;
225225
final emojiUnicode = tryParseEmojiCodeToUnicode(emojiCode)!;
226226
return EmojiCandidate(emojiType: ReactionType.unicodeEmoji,
227-
emojiCode: emojiCode, emojiName: emojiName, aliases: names,
227+
emojiCode: emojiCode, emojiName: emojiName, aliases: aliases,
228228
emojiDisplay: UnicodeEmojiDisplay(
229229
emojiName: emojiName, emojiUnicode: emojiUnicode));
230230
}

0 commit comments

Comments
 (0)