Thanks Javier for the information. Good to know.

Thomas,

I removed "static" from the declaration.

Bye the time window_copy_redraw_screen is called, the old data->cy has
already been clobbered so there is no way of determining which lines must
be withdrawn.  I made window_copy_for_selection it's own function because
there are other places that it could save cycles (ie
window_copy_goto_line, window_copy_scroll_to)
but those changes were outside the scope of this patch.

P.S. I noticed tmux does not use static functions but I couldn't find an
explanation in the repository.  What's the reason for that?

On Wed, Dec 10, 2014 at 7:12 AM, Thomas Adam <tho...@xteddy.org> wrote:

> On Tue, Dec 09, 2014 at 01:45:48AM -0800, Michael Graczyk wrote:
> > +static void
>
> We don't mark functions as static in tmux; not even for the portable
> version.
>
> >                       if (window_copy_update_selection(wp, 1))
> > -                             window_copy_redraw_screen(wp);
> > +                             window_copy_for_selection(wp, old_cy);
>
> Rather than having a new function for this, why not put the logic into
> window_copy_redraw_screen?  The mode for the wp is already known.
>
> -- Thomas Adam
>
From 9896dd10c3f9922a0b0a48799ce5272616a772f3 Mon Sep 17 00:00:00 2001
From: Michael Graczyk <mich...@mgraczyk.com>
Date: Mon, 8 Dec 2014 16:57:49 -0800
Subject: [PATCH] Fix poor performance during mouse mode selection.

---
 window-copy.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/window-copy.c b/window-copy.c
index f597332..54b65d5 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -868,12 +868,34 @@ window_copy_key_numeric_prefix(struct window_pane *wp, int key)
 	return (0);
 }
 
+static void
+window_copy_for_selection(
+		struct window_pane *wp,
+		u_int old_y
+) {
+	struct window_copy_mode_data	*data = wp->modedata;
+	const u_int new_y = data->cy;
+	u_int start, end, lines;
+
+	if (old_y <= new_y) {
+		start = old_y;
+		end = new_y;
+	} else {
+		start = new_y;
+		end = old_y;
+	}
+
+	lines = end - start + 1;
+	window_copy_redraw_lines(wp, start, lines);
+}
+
 void
 window_copy_mouse(struct window_pane *wp, struct session *sess,
     struct mouse_event *m)
 {
 	struct window_copy_mode_data	*data = wp->modedata;
 	struct screen			*s = &data->screen;
+	u_int old_cy;
 	u_int				 i;
 
 	if (m->x >= screen_size_x(s))
@@ -907,9 +929,10 @@ window_copy_mouse(struct window_pane *wp, struct session *sess,
 	 */
 	if (s->mode & MODE_MOUSE_BUTTON) {
 		if (~m->event & MOUSE_EVENT_UP) {
+			old_cy = data->cy;
 			window_copy_update_cursor(wp, m->x, m->y);
 			if (window_copy_update_selection(wp, 1))
-				window_copy_redraw_screen(wp);
+				window_copy_for_selection(wp, old_cy);
 			return;
 		}
 		goto reset_mode;
-- 
2.2.0.rc0.207.ga3a616c

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to