justified icon indicating copy to clipboard operation
justified copied to clipboard

Performance

Open ThomasCZ opened this issue 11 years ago • 2 comments

For longer texts it is extremely slow. The biggest slow down is on the line 167 in Justify.java file. I looked at the code, and I optimized it a lot, but with this line, I have no idea... In Android sources in method setSpan(...) is a lot of IMHO unnecessary code, but I did not find any better solution (except of rendering a whole text by myself). Is it possible to do something? Thanks

ThomasCZ avatar Jul 25 '14 17:07 ThomasCZ

First, let me acknowledge that this is indeed slow on long strings. Getting it to be really fast would involve rewriting most of the text rendering that is done in the Layout classes. It's very unfortunate that those classes are closed.

If setSpan on SpannableString is the problem, then you can replace SpannableString with your own implementation of Spannable by setting the Spannable.Factory on the TextView with: public final void setSpannableFactory(Spannable.Factory factory). Then you can try to optimize the setSpan method in your class, or maybe add a setSpans method to do the changes in bulk rather than settings the spans one by one.

However, in my testing, this was not the point where most of the time was spent. If you managed to optimize the code so that it becomes the main slow down, then I would appreciate if you could share your optimizations. You can do so by sending the files or via a pull request. I will then take a look at it and see if I can help optimize it further.

programingjd avatar Jul 26 '14 10:07 programingjd

just wanted to ad that the setSpan is the line that takes more time in the debugger

muhammedabuali avatar Nov 12 '15 13:11 muhammedabuali