[easytag] Refactor ET_Get_Number_Of_Files_In_Directory()
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Refactor ET_Get_Number_Of_Files_In_Directory()
- Date: Sat, 27 Dec 2014 21:49:18 +0000 (UTC)
commit 94dae722e611172961b619f5f97a49635ffb39ee
Author: David King <amigadave amigadave com>
Date: Sat Dec 27 21:46:24 2014 +0000
Refactor ET_Get_Number_Of_Files_In_Directory()
Generate the collate key for the path once, rather than for each
iteration through the loop.
src/et_core.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/et_core.c b/src/et_core.c
index b539419..bb59ac4 100644
--- a/src/et_core.c
+++ b/src/et_core.c
@@ -4522,23 +4522,32 @@ gboolean ET_File_Name_Convert_Character (gchar *filename_utf8)
guint
ET_Get_Number_Of_Files_In_Directory (const gchar *path_utf8)
{
+ gchar *path_key;
GList *l;
guint count = 0;
g_return_val_if_fail (path_utf8 != NULL, count);
+ path_key = g_utf8_collate_key (path_utf8, -1);
+
for (l = g_list_first (ETCore->ETFileList); l != NULL; l = g_list_next (l))
{
ET_File *ETFile = (ET_File *)l->data;
const gchar *cur_filename_utf8 = ((File_Name *)((GList *)ETFile->FileNameCur)->data)->value_utf8;
gchar *dirname_utf8 = g_path_get_dirname(cur_filename_utf8);
+ gchar *dirname_key = g_utf8_collate_key (dirname_utf8, -1);
- if (g_utf8_collate(dirname_utf8, path_utf8) == 0)
+ if (strcmp (dirname_utf8, path_utf8) == 0)
+ {
count++;
+ }
- g_free(dirname_utf8 );
+ g_free (dirname_utf8);
+ g_free (dirname_key);
}
+ g_free (path_key);
+
return count;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]