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

Improve performance by merging View.substr calls #623

Merged
merged 1 commit into from
Nov 8, 2023

Conversation

jfcherng
Copy link
Contributor

@jfcherng jfcherng commented Nov 8, 2023

The original implementation may call View.substr "the length of the bracket content region" times. Now it's just called once.

In my daily setup which uses

    "search_threshold": 20000, // 5000 by default
    "content_highlight_bar": true,
    "align_content_highlight_bar": true,

This may reduce numbers of View.substr calls from 10k to just 1.

@gir-bot gir-bot added S: needs-review Needs to be reviewed and/or approved. C: regions Related to regions. C: source Related to source code. labels Nov 8, 2023
@jfcherng jfcherng force-pushed the perf/substr branch 2 times, most recently from 2b8eedc to b62d2e5 Compare November 8, 2023 09:05
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
@facelessuser
Copy link
Owner

Looks good. I'll have to verify functionality, but I'm not expecting any issues.

Comment on lines +427 to +430
if any(
char not in whitespace
for char in self.view.substr(sublime.Region(pt, right.begin))
):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: could be extracted into a function and re-used in line 412.

@facelessuser
Copy link
Owner

@gir-bot lgtm

@gir-bot gir-bot added S: approved The pull request is ready to be merged. and removed S: needs-review Needs to be reviewed and/or approved. labels Nov 8, 2023
@facelessuser facelessuser merged commit bd058d7 into facelessuser:master Nov 8, 2023
5 of 6 checks passed
@jfcherng jfcherng deleted the perf/substr branch November 8, 2023 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: regions Related to regions. C: source Related to source code. S: approved The pull request is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants