Skip to content
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

Performance #2

Open
ThomasCZ opened this issue Jul 25, 2014 · 2 comments
Open

Performance #2

ThomasCZ opened this issue Jul 25, 2014 · 2 comments

Comments

@ThomasCZ
Copy link

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

@programingjd
Copy link
Owner

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.

@muhammedabuali
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants