diff options
author | Dave Davenport <qball@gmpclient.org> | 2016-05-22 17:47:34 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2016-05-22 17:47:34 +0200 |
commit | 498fadc735df509ef0a864db1e93d2120d8eb9ee (patch) | |
tree | 8d322b8736c615cc0ba51c9b40ad30d3a9668480 /source/view.c | |
parent | 8091558ed8234914b398fe288aaccfe9770dac9c (diff) |
Remove the is_ascii mess.
Diffstat (limited to 'source/view.c')
-rw-r--r-- | source/view.c | 54 |
1 files changed, 4 insertions, 50 deletions
diff --git a/source/view.c b/source/view.c index 2c98b972..1114c923 100644 --- a/source/view.c +++ b/source/view.c @@ -301,7 +301,6 @@ void rofi_view_free ( RofiViewState *state ) g_free ( state->boxes ); g_free ( state->line_map ); g_free ( state->distance ); - g_free ( state->lines_not_ascii ); // Free the switcher boxes. // When state is free'ed we should no longer need these. if ( config.sidebar_mode == TRUE ) { @@ -465,7 +464,7 @@ static RofiViewState * __rofi_view_state_create ( void ) typedef struct _thread_state { RofiViewState *state; - char **tokens; + GRegex **tokens; unsigned int start; unsigned int stop; unsigned int count; @@ -494,8 +493,7 @@ static void filter_elements ( thread_state *t, G_GNUC_UNUSED gpointer user_data { // input changed for ( unsigned int i = t->start; i < t->stop; i++ ) { - int match = mode_token_match ( t->state->sw, t->tokens, t->state->lines_not_ascii[i], - config.case_sensitive, i ); + int match = mode_token_match ( t->state->sw, t->tokens, i ); // If each token was matched, add it to list. if ( match ) { t->state->line_map[t->start + t->count] = i; @@ -509,12 +507,6 @@ static void filter_elements ( thread_state *t, G_GNUC_UNUSED gpointer user_data } } } -static void check_is_ascii ( thread_state *t, G_GNUC_UNUSED gpointer user_data ) -{ - for ( unsigned int i = t->start; i < t->stop; i++ ) { - t->state->lines_not_ascii[i] = mode_is_not_ascii ( t->state->sw, i ); - } -} static void rofi_view_setup_fake_transparency ( void ) { @@ -933,7 +925,7 @@ static void rofi_view_draw ( RofiViewState *state, cairo_t *d ) int x_offset = state->border; if ( state->rchanged ) { - char **tokens = tokenize ( state->text->text, config.case_sensitive ); + GRegex **tokens = tokenize ( state->text->text, config.case_sensitive ); // Move, resize visible boxes and show them. for ( i = 0; i < max_elements && ( i + offset ) < state->filtered_lines; i++ ) { unsigned int ex = ( ( i ) / state->max_rows ) * ( element_width + config.line_margin ); @@ -1256,7 +1248,7 @@ static void rofi_view_refilter ( RofiViewState *state ) TICK_N ( "Filter start" ); if ( strlen ( state->text->text ) > 0 ) { unsigned int j = 0; - char **tokens = tokenize ( state->text->text, config.case_sensitive ); + GRegex **tokens = tokenize ( state->text->text, config.case_sensitive ); /** * On long lists it can be beneficial to parallelize. * If number of threads is 1, no thread is spawn. @@ -1641,45 +1633,7 @@ RofiViewState *rofi_view_create ( Mode *sw, // Request the lines to show. state->num_lines = mode_get_num_entries ( sw ); - state->lines_not_ascii = g_malloc0_n ( state->num_lines, sizeof ( int ) ); - // find out which lines contain non-ascii codepoints, so we can be faster in some cases. - if ( state->num_lines > 0 ) { - TICK_N ( "Is ASCII start" ); - unsigned int nt = MAX ( 1, state->num_lines / 5000 ); - thread_state states[nt]; - unsigned int steps = ( state->num_lines + nt ) / nt; - unsigned int count = nt; - GCond cond; - GMutex mutex; - g_mutex_init ( &mutex ); - g_cond_init ( &cond ); - for ( unsigned int i = 0; i < nt; i++ ) { - states[i].state = state; - states[i].start = i * steps; - states[i].stop = MIN ( ( i + 1 ) * steps, state->num_lines ); - states[i].acount = &count; - states[i].mutex = &mutex; - states[i].cond = &cond; - states[i].callback = check_is_ascii; - if ( i > 0 ) { - g_thread_pool_push ( tpool, &( states[i] ), NULL ); - } - } - // Run one in this thread. - rofi_view_call_thread ( &( states[0] ), NULL ); - // No need to do this with only one thread. - if ( nt > 1 ) { - g_mutex_lock ( &mutex ); - while ( count > 0 ) { - g_cond_wait ( &cond, &mutex ); - } - g_mutex_unlock ( &mutex ); - } - g_cond_clear ( &cond ); - g_mutex_clear ( &mutex ); - TICK_N ( "Is ASCII stop" ); - } TICK_N ( "Startup notification" ); // Try to grab the keyboard as early as possible. |