mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-12 06:08:25 -05:00
Call the routine to convert emoji to images only when a message actually contains emoji.
This is to solve the performance issue repoted by jesse in Issue 2657. Signed-off-by: HIRANO Takahito <hiranotaka@zng.info>
This commit is contained in:
parent
a0b5aaebb1
commit
4dcf32d2a9
@ -3218,11 +3218,28 @@ public class LocalStore extends Store implements Serializable
|
||||
html = HtmlConverter.textToHtml(text);
|
||||
}
|
||||
|
||||
html = convertEmoji2Img(html);
|
||||
if (hasEmoji(html))
|
||||
html = convertEmoji2Img(html);
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lightweight method to check whether the message contains emoji or not.
|
||||
* Useful to avoid calling the heavyweight convertEmoji2Img method.
|
||||
* We don't use String.codePointAt here for performance reasons.
|
||||
*/
|
||||
private boolean hasEmoji(String html)
|
||||
{
|
||||
for (int i = 0; i < html.length(); ++i)
|
||||
{
|
||||
char c = html.charAt(i);
|
||||
if (c >= 0xDBB8 && c < 0xDBBC)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String convertEmoji2Img(String html)
|
||||
{
|
||||
StringBuilder buff = new StringBuilder(html.length() + 512);
|
||||
|
Loading…
Reference in New Issue
Block a user