[gcompris/gcomprixogoo] Improved the gc_file_find_absolute() to be more readable and probably faster.
- From: Bruno Coudoin <bcoudoin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcompris/gcomprixogoo] Improved the gc_file_find_absolute() to be more readable and probably faster.
- Date: Mon, 1 Nov 2010 23:40:00 +0000 (UTC)
commit 3545070450fb1919492dc49ee3d1ba96683a3a35
Author: Bruno Coudoin <bruno coudoin free fr>
Date: Mon Nov 1 00:28:07 2010 +0100
Improved the gc_file_find_absolute() to be more readable and probably faster.
The easiest case was not treated properly and we were always considering the locale case.
src/gcompris/gameutil.c | 32 ++++++++++++++------------------
1 files changed, 14 insertions(+), 18 deletions(-)
---
diff --git a/src/gcompris/gameutil.c b/src/gcompris/gameutil.c
index 3f4b98f..926d3cb 100644
--- a/src/gcompris/gameutil.c
+++ b/src/gcompris/gameutil.c
@@ -599,21 +599,24 @@ gc_file_find_absolute(const gchar *format, ...)
while (dir_to_search[i])
{
gchar **tmp;
+ gchar **locale;
+ gchar *filename2;
g_free(absolute_filename);
- /* Check there is a $LOCALE to replace */
- if((tmp = g_strsplit(filename, "$LOCALE", -1)))
- {
- gchar **locale;
- gchar *filename2;
+ /* Maybe there is a $LOCALE to replace */
+ tmp = g_strsplit(filename, "$LOCALE", -1);
- locale = g_strsplit_set(gc_locale_get(), ".", 2);
- if(g_strv_length(locale) < 1)
- {
- absolute_filename = g_strdup("");
- goto NOT_FOUND;
- }
+ locale = g_strsplit_set(gc_locale_get(), ".", 2);
+ if(g_strv_length(locale) == 1)
+ {
+ absolute_filename = \
+ g_strdup_printf("%s/%s", dir_to_search[i], filename);
+ if(g_file_test (absolute_filename, G_FILE_TEST_EXISTS))
+ goto FOUND;
+ }
+ else
+ {
/* First try with the long locale */
filename2 = g_strjoinv(locale[0], tmp);
absolute_filename = g_strdup_printf("%s/%s", dir_to_search[i],
@@ -649,13 +652,6 @@ gc_file_find_absolute(const gchar *format, ...)
else
g_strfreev(tmp);
}
- else
- {
- absolute_filename = g_strdup_printf("%s/%s", dir_to_search[i], filename);
-
- if(g_file_test (absolute_filename, G_FILE_TEST_EXISTS))
- goto FOUND;
- }
i++;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]