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

Cache "is_math" state #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mscott99
Copy link

I think the code was checking whether is_math for each snippet for which this was a condition. This pr changes that behaviour so that is_math is a local variable that updates anytime the buffer is modified, and then the is_math condition on the snippets will read off this local variable.

@iurimateus
Copy link
Owner

Have you checked this works for all buffers (i.e. newly created)? I get the impression that on_attach will be called only once, for a single buffer.

@mscott99
Copy link
Author

mscott99 commented Jul 15, 2023

Oh it seems that you are correct. Sometimes on_attach is not called.
I have now fixed this, the buf_attach is now called with an autocommand each time we have a BufEnter or BufWinEnter. Also the is_math variable is now local to each buffer.

@mscott99 mscott99 force-pushed the performance_branch branch from 5fe8051 to 89d64eb Compare July 15, 2023 11:50
@iurimateus
Copy link
Owner

iurimateus commented Jul 24, 2023

Do you have any profiling/benchmark?
I'm curious on how many calls we're saving.

@mscott99
Copy link
Author

I don't, but I could run a quick check with some print statements or a counter to check the number of calls. I wont be able to do that right away though, probably in a week or so

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

Successfully merging this pull request may close these issues.

2 participants