cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=0d0ca579c6697aef93e84c4b8e6993120e18614a

commit 0d0ca579c6697aef93e84c4b8e6993120e18614a
Author: Cedric BAIL <ced...@osg.samsung.com>
Date:   Mon Sep 19 16:07:03 2016 -0700

    elementary: be more conservative on the amount of data requested from disk.
---
 src/lib/elementary/efl_ui_image.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/lib/elementary/efl_ui_image.c 
b/src/lib/elementary/efl_ui_image.c
index 3a28ee4..d4370b6 100644
--- a/src/lib/elementary/efl_ui_image.c
+++ b/src/lib/elementary/efl_ui_image.c
@@ -249,7 +249,6 @@ _efl_ui_image_async_open_do(void *data, Ecore_Thread 
*thread)
    Async_Open_Data *todo = data;
    Eina_File *f;
    void *map = NULL;
-   unsigned char *p, sum = 0;
    size_t i, size;
 
    if (ecore_thread_check(thread)) return;
@@ -273,17 +272,13 @@ _efl_ui_image_async_open_do(void *data, Ecore_Thread 
*thread)
      }
 
    // Read just enough data for map to actually do something.
-   p = map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
    size = eina_file_size_get(f);
    // Read and ensure all pages are in memory for sure first just
    // 1 byte per page will do. also keep a limit on how much we will
-   // blindly load in here to let's say 512M
-   if (size > (512 * 1024 * 1024)) size = 512 * 1024 * 1024;
-   for (i = 0; i < size; i += 4096)
-     {
-        if (ecore_thread_check(thread)) break;
-        sum += p[i];
-     }
+   // blindly load in here to let's say 32KB (Should be enough to get
+   // image headers without getting to much data from the hard drive).
+   size = size > 32 * 1024 ? 32 * 1024 : size;
+   map = eina_file_map_new(f, EINA_FILE_POPULATE, 0, size);
 
    if (ecore_thread_check(thread))
      {

-- 


Reply via email to