From ec8f1f90146516b19161d8d88b080add8e6edc46 Mon Sep 17 00:00:00 2001 From: Dominic Fellbaum Date: Thu, 26 Oct 2023 07:33:15 +0200 Subject: [PATCH] Small cleanup in EmojiManager --- .../main/java/net/fellbaum/jemoji/EmojiManager.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/src/main/java/net/fellbaum/jemoji/EmojiManager.java b/lib/src/main/java/net/fellbaum/jemoji/EmojiManager.java index b62c98f..3f9f709 100644 --- a/lib/src/main/java/net/fellbaum/jemoji/EmojiManager.java +++ b/lib/src/main/java/net/fellbaum/jemoji/EmojiManager.java @@ -18,7 +18,7 @@ @SuppressWarnings("unused") public final class EmojiManager { - private static final String PATH = "emojis.json"; + private static final String PATH = "emoji_sources/emojis.json"; private static final Map EMOJI_UNICODE_TO_EMOJI; private static final Map> EMOJI_FIRST_CODEPOINT_TO_EMOJIS_ORDER_CODEPOINT_LENGTH_DESCENDING; @@ -282,7 +282,8 @@ public static List extractEmojisInOrder(final String text) { nextTextIteration: for (int textIndex = 0; textIndex < textCodePointsLength; textIndex++) { - final List emojisByCodePoint = EMOJI_FIRST_CODEPOINT_TO_EMOJIS_ORDER_CODEPOINT_LENGTH_DESCENDING.get(textCodePointsArray[textIndex]); + final int currentCodepoint = textCodePointsArray[textIndex]; + final List emojisByCodePoint = EMOJI_FIRST_CODEPOINT_TO_EMOJIS_ORDER_CODEPOINT_LENGTH_DESCENDING.get(currentCodepoint); if (emojisByCodePoint == null) continue; for (final Emoji emoji : emojisByCodePoint) { final int[] emojiCodePointsArray = emoji.getEmoji().codePoints().toArray(); @@ -292,11 +293,11 @@ public static List extractEmojisInOrder(final String text) { continue; } - for (int i = 0; i < emojiCodePointsLength; i++) { - if (textCodePointsArray[textIndex + i] != emojiCodePointsArray[i]) { + for (int emojiCodePointIndex = 0; emojiCodePointIndex < emojiCodePointsLength; emojiCodePointIndex++) { + if (textCodePointsArray[textIndex + emojiCodePointIndex] != emojiCodePointsArray[emojiCodePointIndex]) { break; } - if (i == emojiCodePointsLength - 1) { + if (emojiCodePointIndex == (emojiCodePointsLength - 1)) { emojis.add(emoji); textIndex += emojiCodePointsLength - 1; continue nextTextIteration;