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

Count just enough lines for half page scrolling #14652

Closed
wants to merge 1 commit into from

Conversation

luukvbaal
Copy link
Contributor

Problem: Calculating line height for unnecessary amount of lines with
half-page scrolling.
Solution: Replace "limit_winheight" argument with higher resolution
"max" argument to which to limit the calculated line height
in plines_m_win() to.

Fix #14650

@luukvbaal
Copy link
Contributor Author

luukvbaal commented Apr 27, 2024

Could also add this cheap check that determines whether calling plines_m_win() is even necessary to begin with, although that only works if the window has no folds:

@@ -3219,7 +3219,8 @@ pagescroll(int dir, long count, int half)

        int curscount = count;
        // Adjust count so as to not reveal end of buffer lines.
-       if (dir == FORWARD)
+       if (dir == FORWARD && (hasAnyFolding(curwin)
+                   || curwin->w_topline + count > buflen - curwin->w_height))
        {
            int n = plines_correct_topline(curwin, curwin->w_topline, FALSE);
            if (n - count < curwin->w_height && curwin->w_topline < buflen)

@luukvbaal luukvbaal force-pushed the pagescroll branch 3 times, most recently from 3cc10a7 to 8336230 Compare April 27, 2024 22:53
Problem:  Calculating line height for unnecessary amount of lines with
          half-page scrolling.
Solution: Replace "limit_winheight" argument with higher resolution
          "max" argument to which to limit the calculated line height
          in plines_m_win() to.
@zhscn
Copy link

zhscn commented Apr 28, 2024

I just applied this PR and the CPU usage goes down to 3.5%. 👍

@chrisbra
Copy link
Member

thanks!

@chrisbra chrisbra closed this in 32d701f Apr 28, 2024
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.

High CPU usage on Fedora 40
3 participants