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 tuning #197

Open
obecker opened this issue Jun 20, 2021 · 2 comments
Open

Performance tuning #197

obecker opened this issue Jun 20, 2021 · 2 comments

Comments

@obecker
Copy link
Contributor

obecker commented Jun 20, 2021

The performance of the rendering process can be improved by

  • changing the TextEscaper interface method to void appendEscaped(Appendable out, String text); - thus preventing the intermediate step of creating a new String containing the escaped text
  • changing the Indenter interface method to void appendIndented(Appendable out, int level, String text); - same idea: don't create a temporary string, but write indent and text directly to out

I'm not sure if this can be realized in a backward compatible way - so probably this is something for 2.0

@sembler
Copy link
Collaborator

sembler commented Jun 21, 2021

I like this idea. I'd take it further for the Indenter and say that we don't need to pass in the text anymore. We'd just need to represent the indentation itself: Indentation.append(int level, Appendable out) since the text can be appended by the caller at some point in the future.

I think it is worth focusing on 2.0 right now; to clean away the deprecated items and fix the API difficulties that we've come to recognize over the past few months.

@obecker
Copy link
Contributor Author

obecker commented Jun 21, 2021

I'd take it further for the Indenter and say that we don't need to pass in the text anymore. We'd just need to represent the indentation itself: Indentation.append(int level, Appendable out) since the text can be appended by the caller at some point in the future.

Yes, definitely. Otherwise it would be difficult to combine the two aspects (the indented text needs also to be escaped).

Concerning the TextEscaper: another possibility would be to wrap or decorate the given Appendable by an EscapingAppendable when writing text contents and attribute values.

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

No branches or pull requests

2 participants