Skip to content

Commit cb574f4

Browse files
committed
patch 8.1.0822: peeking and flushing output slows down execution
Problem: Peeking and flushing output slows down execution. Solution: Do not update the mode message when global_busy is set. Do not flush when only peeking for a character. (Ken Takata)
1 parent 970f5d3 commit cb574f4

5 files changed

Lines changed: 29 additions & 13 deletions

File tree

src/edit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8722,7 +8722,7 @@ ins_esc(
87228722
*/
87238723
if (reg_recording != 0 || restart_edit != NUL)
87248724
showmode();
8725-
else if (p_smd)
8725+
else if (p_smd && !skip_showmode())
87268726
msg("");
87278727

87288728
return TRUE; /* exit Insert mode */

src/getchar.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3039,9 +3039,10 @@ inchar(
30393039

30403040
/*
30413041
* Always flush the output characters when getting input characters
3042-
* from the user.
3042+
* from the user and not just peeking.
30433043
*/
3044-
out_flush();
3044+
if (wait_time == -1L || wait_time > 10L)
3045+
out_flush();
30453046

30463047
/*
30473048
* Fill up to a third of the buffer, because each character may be

src/proto/screen.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ int win_ins_lines(win_T *wp, int row, int line_count, int invalid, int mayclear)
4949
int win_del_lines(win_T *wp, int row, int line_count, int invalid, int mayclear, int clear_attr);
5050
int screen_ins_lines(int off, int row, int line_count, int end, int clear_attr, win_T *wp);
5151
int screen_del_lines(int off, int row, int line_count, int end, int force, int clear_attr, win_T *wp);
52+
int skip_showmode(void);
5253
int showmode(void);
5354
void unshowmode(int force);
5455
void clearmode(void);

src/screen.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10109,6 +10109,26 @@ screen_del_lines(
1010910109
return OK;
1011010110
}
1011110111

10112+
/*
10113+
* Return TRUE when postponing displaying the mode message: when not redrawing
10114+
* or inside a mapping.
10115+
*/
10116+
int
10117+
skip_showmode()
10118+
{
10119+
// Call char_avail() only when we are going to show something, because it
10120+
// takes a bit of time. redrawing() may also call char_avail_avail().
10121+
if (global_busy
10122+
|| msg_silent != 0
10123+
|| !redrawing()
10124+
|| (char_avail() && !KeyTyped))
10125+
{
10126+
redraw_cmdline = TRUE; // show mode later
10127+
return TRUE;
10128+
}
10129+
return FALSE;
10130+
}
10131+
1011210132
/*
1011310133
* Show the current mode and ruler.
1011410134
*
@@ -10135,16 +10155,8 @@ showmode(void)
1013510155
|| VIsual_active));
1013610156
if (do_mode || reg_recording != 0)
1013710157
{
10138-
/*
10139-
* Don't show mode right now, when not redrawing or inside a mapping.
10140-
* Call char_avail() only when we are going to show something, because
10141-
* it takes a bit of time.
10142-
*/
10143-
if (!redrawing() || (char_avail() && !KeyTyped) || msg_silent != 0)
10144-
{
10145-
redraw_cmdline = TRUE; /* show mode later */
10146-
return 0;
10147-
}
10158+
if (skip_showmode())
10159+
return 0; // show mode later
1014810160

1014910161
nwr_save = need_wait_return;
1015010162

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,8 @@ static char *(features[]) =
787787

788788
static int included_patches[] =
789789
{ /* Add new patch number below this line */
790+
/**/
791+
822,
790792
/**/
791793
821,
792794
/**/

0 commit comments

Comments
 (0)