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

Don't g_strsplit everytime, use strtok.

This commit is contained in:
Dave Davenport 2017-03-06 09:56:02 +01:00
parent 45c70cbecf
commit 9938317dc5
3 changed files with 9 additions and 5 deletions

View file

@ -108,7 +108,7 @@ PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.40 gio-unix-2.0 gmodule-2.0])
GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon >= 0.5.0 xkbcommon-x11 xcb-ewmh xcb-icccm xcb-xrm xcb-randr xcb-xinerama])
PKG_CHECK_MODULES([pango], [pango pangocairo])
PKG_CHECK_MODULES([cairo], [cairo cairo-xcb])
PKG_CHECK_MODULES([libsn], [libstartup-notification-1.0])
PKG_CHECK_MODULES([libsn], [libstartup-notification-1.0 libprofiler])
dnl ---------------------------------------------------------------------

View file

@ -1025,14 +1025,17 @@ int main ( int argc, char *argv[] )
if ( !dmenu_mode ) {
// setup_modi
setup_modi ();
TICK_N ( "Setup Modi" );
}
if ( find_arg ( "-no-config" ) < 0 ) {
// Reload for dynamic part.
load_configuration_dynamic ( );
TICK_N ( "Load config dynamic" );
}
// Parse command line for settings, independent of other -no-config.
config_parse_cmd_options_dynamic ( );
TICK_N ( "Load cmd config dynamic" );
if ( config.theme ) {
TICK_N ( "Parse theme" );

View file

@ -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;
}