-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emoji processing is very slow #63
Comments
Try to restrict the range on which operations are performed. There are a lot of corner cases that may not work properly, but at least it’s a lot faster now.
I tried improving the substitution logic in febfcdd. Can you maybe give it a try? |
Would it make sense to first check the entire string for a known pattern (if one exists) and only when found, then loop through the string? |
Another possible option would be to store a hash of strings encountered that have no emoji sequences. |
Initially, I thought that the problem was in rendering, but after debugging, I realized that this was not the case. Iterating through the richedit characters and getting the range is very slow! I spent some time thinking that this can be done simply, but then I realized that this is not the case and I need to radically change the logic for replacing text with emoji. But my attempts were not successful due to the nuances of processing emoji, etc. |
Yes,
|
Hi, it's not perfect yet, but I modified the SubstituteGlyphsInRange method so that it no longer iterates through the entire string of characters. It only processes the emojis.
The first search for an emoji is a bit slow. But after that, regardless of the size of the text, it remains fast. |
Hi, Swindler95 var matches = emojiRegex.Matches(text); // where is object emojiRegex? |
Hi, @GLEB-M Sorry, I forgot to add the variable: |
Swindler95, I tried to use your code, but this doesn't work properly |
I said it wasn't perfect 😄, in fact I'm only using this new method for input because I need to be able to type a large amount of text with few emojis, and it works very well. With the old SubstituteGlyphsInRange, the more text there is, the longer it takes to process and it becomes really unusable. However, I've developed a new class called "RichTextBlock" for displaying the text that uses the old SubstituteGlyphsInRange, which is more stable for displaying all emojis correctly. I'll continue working on improving this method, but if anyone else wants to improve it, I'm open to it. 😉 |
I did some profiling on this project and i see sostituteglyphinrange is called a ton of times. I was thinking: maybe one improvement could be render a line then cache it, render everything only if the container is resized horizontally (vertically for top down languages?) Not sure what the hlsl nuget package is doing but if we could store those cached bitmaps in graphic card mem, that would be even faster, and memory efficient |
FlowDocumentExtensions.cs, SubstituteGlyphs method
This code is very slow! If only 100 or more characters are printed, lag occurs.
replace_range.Text - getting text from range for each character is not fast operation for richedit
What about optimizing this?
The text was updated successfully, but these errors were encountered: