eio: make xattr list packed for better performance.
authorCedric BAIL <cedric@osg.samsung.com>
Wed, 7 Sep 2016 22:57:25 +0000 (15:57 -0700)
committerCedric BAIL <cedric@osg.samsung.com>
Thu, 8 Sep 2016 22:16:43 +0000 (15:16 -0700)
src/lib/eio/eio_xattr.c

index a795b95..0dfec5b 100644 (file)
@@ -33,11 +33,17 @@ _eio_ls_xattr_heavy(void *data, Ecore_Thread *thread)
 {
    Eio_File_Char_Ls *async = data;
    Eina_Iterator *it;
+   Eina_List *pack = NULL;
    const char *tmp;
+   double start;
 
    it = eina_xattr_ls(async->ls.directory);
    if (!it) return;
 
+   eio_file_container_set(&async->ls.common, eina_iterator_container_get(it));
+
+   start = ecore_time_get();
+
    EINA_ITERATOR_FOREACH(it, tmp)
      {
         Eina_Bool filter = EINA_TRUE;
@@ -49,22 +55,38 @@ _eio_ls_xattr_heavy(void *data, Ecore_Thread *thread)
                                        tmp);
           }
 
-        if (filter) ecore_thread_feedback(thread, eina_stringshare_add(tmp));
+        if (filter)
+          {
+             Eio_File_Char *send_fc;
+
+             send_fc = eio_char_malloc();
+             if (!send_fc) goto on_error;
+
+             send_fc->filename = eina_stringshare_add(tmp);
+             send_fc->associated = async->ls.common.worker.associated;
+             async->ls.common.worker.associated = NULL;
+
+             pack = eina_list_append(pack, send_fc);
+          }
+        else
+          {
+          on_error:
+             if (async->ls.common.worker.associated)
+               {
+                  eina_hash_free(async->ls.common.worker.associated);
+                  async->ls.common.worker.associated = NULL;
+               }
+          }
+
+        pack = eio_pack_send(thread, pack, &start);
 
         if (ecore_thread_check(thread))
           break;
      }
 
-   eina_iterator_free(it);
-}
-
-static void
-_eio_ls_xattr_notify(void *data, Ecore_Thread *thread EINA_UNUSED, void *msg_data)
-{
-   Eio_File_Char_Ls *async = data;
-   const char *xattr = msg_data;
+   if (pack) ecore_thread_feedback(thread, pack);
 
-   async->main_cb((void*) async->ls.common.data, &async->ls.common, xattr);
+   async->ls.ls = it;
 }
 
 static void
@@ -310,7 +332,7 @@ eio_file_xattr(const char *path,
                          error_cb,
                          data,
                          _eio_ls_xattr_heavy,
-                         _eio_ls_xattr_notify,
+                         _eio_string_notify,
                          eio_async_end,
                          eio_async_error))
     return NULL;