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

markAll() - slow for many matches #99

Closed
vadi2 opened this issue May 29, 2020 · 3 comments
Closed

markAll() - slow for many matches #99

vadi2 opened this issue May 29, 2020 · 3 comments

Comments

@vadi2
Copy link
Contributor

vadi2 commented May 29, 2020

We've got this bit of code that we're using to highlight search matches:

    auto controller = mpSourceEditorEdbee->controller();
    auto searcher = controller->textSearcher();
    controller->borderedTextRanges()->clear();
    controller->textSelection()->range(0).clearSelection();
    searcher->setSearchTerm(text);
    searcher->markAll(controller->borderedTextRanges());
    controller->update();

And when we use it on say a 1,000 line document like this, highlighting a single character like c takes a really long while:

Selection_142

Are we using the API right or is there something that can be done?

We've already disabled highlighting for one or two character searches, but that's more of a workaround than a solution, since VS Code on the same machine handles it okay.

@gamecreature
Copy link
Member

That does't sound very good. I have to look into this. ( Unfortunately I don't have much time these days for Edbee).

My first impression is that the markAll and searchAll functions are very inefficient, because it uses a 'findNextRange' call for every item searched.

FindNextRange is a method that can called separately.
A much better approach would be to use 1 call that uses the regexp just once in a loop.
So an optimised rewrite of markAll without calling findNextRange would be a solution

Btw. VSCode probably uses threading for searching in the background.

gamecreature added a commit that referenced this issue Jul 27, 2020
@gamecreature
Copy link
Member

@vadi2 Could you check if this improves the situation?

SlySven pushed a commit to SlySven/edbee-lib that referenced this issue Oct 27, 2020
@vadi2
Copy link
Contributor Author

vadi2 commented Apr 13, 2021

We are good on this now, thank you 👍

@vadi2 vadi2 closed this as completed Apr 13, 2021
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