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, GString *res,
gpointer data ) gpointer data )
{ {
gchar *match, *r; gchar *match;
// Get the match // Get the match
match = g_match_info_fetch ( info, 0 ); match = g_match_info_fetch ( info, 0 );
if ( match != NULL ) { if ( match != NULL ) {
// Lookup the match, so we can replace it. // 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 ) { if ( r != NULL ) {
// Append the replacement to the string. // Append the replacement to the string.
g_string_append ( res, r ); g_string_append ( res, r );

View File

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