[evince] shell: increase search performance. Fixes #667569.



commit bee8bc65e9a62c9e7158f321b83efc7592e37a79
Author: Germán Poo-Caamaño <gpoo gnome org>
Date:   Wed Feb 27 19:45:06 2013 -0800

    shell: increase search performance. Fixes #667569.
    
    Reduces text search duration by reducing the update frequency.
    
    For documents with 100 pages or less, the GUI is updated for
    every page.  For documents between 101 and 200 pages, the GUI
    will be updated every other page, between 201 and 300, the GUI
    will be updated every 3 pages, and so on.
    
    In the PDF reference 1.7 (1310 pages), searching a word like
    Quadrilat, the number of status updates in the GUI went down
    from 1310 to 93 times, that also reduced the time taken to show
    the first match (in page 612) from ~11 secs to ~6 secs.

 shell/ev-window.c |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 1f57146..626aebc 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -277,6 +277,8 @@ struct _EvWindowPrivate {
 #define FULLSCREEN_MOTION_TIME 200 /* in milliseconds */
 #define FULLSCREEN_MOTION_NUM_EVENTS 15
 
+#define FIND_PAGE_RATE_REFRESH 100
+
 static const gchar *document_print_settings[] = {
        GTK_PRINT_SETTINGS_N_COPIES,
        GTK_PRINT_SETTINGS_COLLATE,
@@ -5224,13 +5226,39 @@ ev_window_find_job_finished_cb (EvJobFind *job,
        ev_window_update_find_status_message (ev_window);
 }
 
+/**
+  * find_bar_check_refresh_rate:
+  *
+  * Check whether the current page should trigger an status update in the
+  * find bar given its document size and the rate page.
+  *
+  * For documents with less pages than page_rate, it will return TRUE for
+  * every page.  For documents with more pages, it will return TRUE every
+  * ((total_pages / page rate) + 1).
+  *
+  * This slow down the update rate in the GUI, making the search more
+  * responsive.
+  */
+static inline gboolean
+find_check_refresh_rate (EvJobFind *job, gint page_rate)
+{
+       return ((job->current_page % (gint)((job->n_pages / page_rate) + 1)) == 0);
+}
+
 static void
 ev_window_find_job_updated_cb (EvJobFind *job,
                               gint       page,
                               EvWindow  *ev_window)
 {
-       ev_window_update_actions_sensitivity (ev_window);
-       ev_window_update_find_status_message (ev_window);
+       /* Adjust the status update when searching for a term according
+        * to the document size in pages.  For documents smaller (or equal)
+        * than 100 pages, it will be updated in every page.  A value of
+        * 100 is enough to update the find bar every 1%.
+        */
+       if (find_check_refresh_rate (job, FIND_PAGE_RATE_REFRESH)) {
+               ev_window_update_actions_sensitivity (ev_window);
+               ev_window_update_find_status_message (ev_window);
+       }
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]