Skip to content

Commit

Permalink
Small cleanup in EmojiManager
Browse files Browse the repository at this point in the history
  • Loading branch information
felldo committed Oct 26, 2023
1 parent 09605d6 commit ec8f1f9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/src/main/java/net/fellbaum/jemoji/EmojiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Emoji> EMOJI_UNICODE_TO_EMOJI;
private static final Map<Integer, List<Emoji>> EMOJI_FIRST_CODEPOINT_TO_EMOJIS_ORDER_CODEPOINT_LENGTH_DESCENDING;
Expand Down Expand Up @@ -282,7 +282,8 @@ public static List<Emoji> extractEmojisInOrder(final String text) {

nextTextIteration:
for (int textIndex = 0; textIndex < textCodePointsLength; textIndex++) {
final List<Emoji> emojisByCodePoint = EMOJI_FIRST_CODEPOINT_TO_EMOJIS_ORDER_CODEPOINT_LENGTH_DESCENDING.get(textCodePointsArray[textIndex]);
final int currentCodepoint = textCodePointsArray[textIndex];
final List<Emoji> 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();
Expand All @@ -292,11 +293,11 @@ public static List<Emoji> 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;
Expand Down

0 comments on commit ec8f1f9

Please sign in to comment.