1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Small cleanup and reducing of scopes.

This commit is contained in:
Dave Davenport 2015-01-15 17:59:59 +01:00
parent 1a85fcbf96
commit a00cfbb5b0
2 changed files with 9 additions and 10 deletions

View file

@ -45,12 +45,12 @@ static gboolean helper_eval_cb ( const GMatchInfo *info,
GString *res,
gpointer data )
{
gchar *match, *r;
gchar *match;
// Get the match
match = g_match_info_fetch ( info, 0 );
if ( match != NULL ) {
// Lookup the match, so we can replace it.
r = g_hash_table_lookup ( (GHashTable *) data, match );
gchar *r = g_hash_table_lookup ( (GHashTable *) data, match );
if ( r != NULL ) {
// Append the replacement to the string.
g_string_append ( res, r );

View file

@ -294,7 +294,6 @@ int winlist_find ( winlist *l, Window w )
// iterate backwards. theory is: windows most often accessed will be
// nearer the end. testing with kcachegrind seems to support this...
int i;
Window o = 0;
for ( i = ( l->len - 1 ); i >= 0; i-- ) {
if ( l->array[i] == w ) {
@ -1272,12 +1271,12 @@ static void menu_mouse_navigation ( MenuState *state, XButtonEvent *xbe )
static void menu_refilter ( MenuState *state, char **lines, menu_match_cb mmc, void *mmc_data,
int sorting, int case_sensitive )
{
unsigned int i, j = 0;
if ( strlen ( state->text->text ) > 0 ) {
unsigned int j = 0;
char **tokens = tokenize ( state->text->text, case_sensitive );
// input changed
for ( i = 0; i < state->num_lines; i++ ) {
for ( unsigned int i = 0; i < state->num_lines; i++ ) {
int match = mmc ( tokens, lines[i], case_sensitive, i, mmc_data );
// If each token was matched, add it to list.
@ -1303,10 +1302,10 @@ static void menu_refilter ( MenuState *state, char **lines, menu_match_cb mmc, v
qsort_r ( state->line_map, j, sizeof ( int ), lev_sort, state->distance );
}
// Update the filtered list.
for ( i = 0; i < j; i++ ) {
for ( unsigned int i = 0; i < j; i++ ) {
state->filtered[i] = lines[state->line_map[i]];
}
for ( i = j; i < state->num_lines; i++ ) {
for ( unsigned int i = j; i < state->num_lines; i++ ) {
state->filtered[i] = NULL;
}
@ -1315,7 +1314,7 @@ static void menu_refilter ( MenuState *state, char **lines, menu_match_cb mmc, v
g_strfreev ( tokens );
}
else{
for ( i = 0; i < state->num_lines; i++ ) {
for ( unsigned int i = 0; i < state->num_lines; i++ ) {
state->filtered[i] = lines[i];
state->line_map[i] = i;
}