mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Avoid calling collate when not needed.
This commit is contained in:
parent
b882d9ab72
commit
eae9fe7f04
1 changed files with 17 additions and 16 deletions
|
@ -288,37 +288,38 @@ static int window_match ( char **tokens, __attribute__( ( unused ) ) const char
|
|||
client *c = window_client ( display, ids->array[index] );
|
||||
|
||||
if ( tokens ) {
|
||||
// Create collate keys.
|
||||
char *title_key = token_collate_key ( c->title, case_sensitive );
|
||||
char *class_key = token_collate_key ( c->class, case_sensitive );
|
||||
char *role_key = token_collate_key ( c->role, case_sensitive );
|
||||
char *name_key = token_collate_key ( c->name, case_sensitive );
|
||||
for ( int j = 0; match && tokens[j]; j++ ) {
|
||||
int test = 0;
|
||||
|
||||
if ( !test && c->title[0] != '\0' ) {
|
||||
char *key = token_collate_key ( c->title, case_sensitive );
|
||||
test = ( strstr ( key, tokens[j] ) != NULL );
|
||||
g_free ( key );
|
||||
if ( !test && title_key[0] != '\0' ) {
|
||||
test = ( strstr ( title_key, tokens[j] ) != NULL );
|
||||
}
|
||||
|
||||
if ( !test && c->class[0] != '\0' ) {
|
||||
char *key = token_collate_key ( c->class, case_sensitive );
|
||||
test = ( strstr ( key, tokens[j] ) != NULL );
|
||||
g_free ( key );
|
||||
if ( !test && class_key[0] != '\0' ) {
|
||||
test = ( strstr ( class_key, tokens[j] ) != NULL );
|
||||
}
|
||||
|
||||
if ( !test && c->role[0] != '\0' ) {
|
||||
char *key = token_collate_key ( c->role, case_sensitive );
|
||||
test = ( strstr ( key, tokens[j] ) != NULL );
|
||||
g_free ( key );
|
||||
if ( !test && role_key[0] != '\0' ) {
|
||||
test = ( strstr ( role_key, tokens[j] ) != NULL );
|
||||
}
|
||||
|
||||
if ( !test && c->name[0] != '\0' ) {
|
||||
char *key = token_collate_key ( c->name, case_sensitive );
|
||||
test = ( strstr ( key, tokens[j] ) != NULL );
|
||||
g_free ( key );
|
||||
if ( !test && name_key[0] != '\0' ) {
|
||||
test = ( strstr ( name_key, tokens[j] ) != NULL );
|
||||
}
|
||||
|
||||
if ( test == 0 ) {
|
||||
match = 0;
|
||||
}
|
||||
}
|
||||
g_free ( title_key );
|
||||
g_free ( class_key );
|
||||
g_free ( role_key );
|
||||
g_free ( name_key );
|
||||
}
|
||||
|
||||
return match;
|
||||
|
|
Loading…
Reference in a new issue