Skip to content

Commit f66c812

Browse files
committed
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 774542e commit f66c812

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
@@ -216,11 +216,11 @@ class EmojiStoreImpl extends PerAccountStoreBase with EmojiStore {
216216

217217
static List<EmojiCandidate> _generatePopularCandidates() {
218218
EmojiCandidate candidate(String emojiCode, List<String> names) {
219-
final emojiName = names.removeAt(0);
219+
final [emojiName, ...aliases] = names;
220220
final emojiUnicode = tryParseEmojiCodeToUnicode(emojiCode);
221221
assert(emojiUnicode != null);
222222
return EmojiCandidate(emojiType: ReactionType.unicodeEmoji,
223-
emojiCode: emojiCode, emojiName: emojiName, aliases: names,
223+
emojiCode: emojiCode, emojiName: emojiName, aliases: aliases,
224224
emojiDisplay: UnicodeEmojiDisplay(
225225
emojiName: emojiName, emojiUnicode: emojiUnicode!));
226226
}

0 commit comments

Comments
 (0)