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 issues #38

Closed
IvanMathy opened this issue Jun 16, 2020 · 5 comments
Closed

Performance issues #38

IvanMathy opened this issue Jun 16, 2020 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@IvanMathy
Copy link
Owner

Currently, the syntax highlighting is not super optimized, which cause performance issues on large strings.

Possible solutions:

  • Migrate away from regex (Would this help?)
  • Disable any multi-line regex, to see if it speeds things up.
  • Add lazy highlighting. Only highlight viewport, and only when changed.
@IvanMathy IvanMathy added enhancement New feature or request help wanted Extra attention is needed labels Jun 16, 2020
@fnky
Copy link
Contributor

fnky commented Jun 16, 2020

I think most of the performance can be won by the third solution. This is a common solution in most IDEs which also use regex-based syntax highlighting.

Not sure what you mean by the following:

Only highlight viewport, and only when changed

Is it when viewport has changed (e.g. resizing, scrolling) or upon changing the content?

@IvanMathy
Copy link
Owner Author

Is it when viewport has changed (e.g. resizing, scrolling) or upon changing the content?

Both, though I'd say the first step would be only when changing the content, on a line-per-line basis. Since it's using NSAttributedString in the background, resizing and scrill won't change anything if the whole thing already got rendered.

@fnky
Copy link
Contributor

fnky commented Jun 17, 2020

Wouldn’t this mean that pasting large amount of text would be slow if it had to parse all the text to highlight it.

I can see an issue if it only highlights the text that is visible in the viewport. Scrolling and resize would not update the highlighting.

@IvanMathy
Copy link
Owner Author

Correct, first paste would be a bit slow but I think that's an ok tradeoff for a first improvement. The biggest issue right now is the slowness when typing in a large document

@IvanMathy IvanMathy added this to the Release 1.2.0 milestone Jun 28, 2020
@IvanMathy
Copy link
Owner Author

Fixed in release 1.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants