Skip to content

Commit

Permalink
Merge pull request #48815 from Expensify/cmartins-fixCrashOnTiming
Browse files Browse the repository at this point in the history
[CP Staging] Fix crash on timing

(cherry picked from commit bfd1512)

(CP triggered by luacmartins)
  • Loading branch information
luacmartins authored and OSBotify committed Sep 9, 2024
1 parent 9a3e806 commit 0bd4e75
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/libs/EmojiTrie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ type EmojiMetaData = {
name?: string;
};

Timing.start(CONST.TIMING.TRIE_INITIALIZATION);

const supportedLanguages = [CONST.LOCALES.DEFAULT, CONST.LOCALES.ES] as const;

type SupportedLanguage = TupleToUnion<typeof supportedLanguages>;
Expand Down Expand Up @@ -123,6 +121,7 @@ const emojiTrie: EmojiTrie = supportedLanguages.reduce((acc, lang) => {
}, {} as EmojiTrie);

const buildEmojisTrie = (locale: Locale) => {
Timing.start(CONST.TIMING.TRIE_INITIALIZATION);
// Normalize the locale to lowercase and take the first part before any dash
const normalizedLocale = locale.toLowerCase().split('-')[0];
const localeToUse = supportedLanguages.includes(normalizedLocale as SupportedLanguage) ? (normalizedLocale as SupportedLanguage) : undefined;
Expand All @@ -131,10 +130,9 @@ const buildEmojisTrie = (locale: Locale) => {
return; // Return early if the locale is not supported or the trie is already built
}
emojiTrie[localeToUse] = createTrie(localeToUse);
Timing.end(CONST.TIMING.TRIE_INITIALIZATION);
};

Timing.end(CONST.TIMING.TRIE_INITIALIZATION);

export default emojiTrie;
export {buildEmojisTrie};

Expand Down

0 comments on commit 0bd4e75

Please sign in to comment.