summaryrefslogtreecommitdiffstats
path: root/source/theme.c
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-03-06 09:56:02 +0100
committerDave Davenport <qball@gmpclient.org>2017-03-06 09:56:02 +0100
commit9938317dc5ef1d1abc3b1b92792fe49116e41daa (patch)
tree4d1d6bf698746e05394d305e80d50497dd7eb44d /source/theme.c
parent45c70cbecf980769ec5cda10e1186bf3d7dcb580 (diff)
Don't g_strsplit everytime, use strtok.
Diffstat (limited to 'source/theme.c')
-rw-r--r--source/theme.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/source/theme.c b/source/theme.c
index 7c49a9ae..13d9de44 100644
--- a/source/theme.c
+++ b/source/theme.c
@@ -314,17 +314,18 @@ static ThemeWidget *rofi_theme_find ( ThemeWidget *widget, const char *name, con
if ( widget == NULL || name == NULL ) {
return widget;
}
- char **names = g_strsplit ( name, ".", 0 );
+ char *tname = g_strdup(name );
+ char *saveptr = NULL;
int found = TRUE;
- for ( unsigned int i = 0; found && names && names[i]; i++ ) {
+ for (const char *iter = strtok_r (tname, ".", &saveptr); iter != NULL ; iter = strtok_r ( NULL, "." , &saveptr ) ) {
found = FALSE;
- ThemeWidget *f = rofi_theme_find_single ( widget, names[i] );
+ ThemeWidget *f = rofi_theme_find_single ( widget, iter );
if ( f != widget ) {
widget = f;
found = TRUE;
}
}
- g_strfreev ( names );
+ g_free ( tname );
if ( !exact || found ) {
return widget;
}