mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
优化EMOJ查询逻辑
This commit is contained in:
parent
870ea9a329
commit
9b9173b230
@ -38,22 +38,7 @@ public class EmojiUtil {
|
|||||||
* @since 4.5.11
|
* @since 4.5.11
|
||||||
*/
|
*/
|
||||||
public static boolean containsEmoji(String str) {
|
public static boolean containsEmoji(String str) {
|
||||||
if (str == null) {
|
return EmojiManager.containsEmoji(str);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final char[] chars = str.toCharArray();
|
|
||||||
EmojiTrie.Matches status;
|
|
||||||
for (int i = 0; i < chars.length; i++) {
|
|
||||||
for (int j = i + 1; j <= chars.length; j++) {
|
|
||||||
status = EmojiManager.isEmoji(Arrays.copyOfRange(chars, i, j));
|
|
||||||
if (status.impossibleMatch()) {
|
|
||||||
break;
|
|
||||||
} else if (status.exactMatch()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user