On Wed, Mar 10, 2010 at 6:33 PM, Enlightenment SVN
<no-re...@enlightenment.org> wrote:
> Log:
>  read user dir cache
> Author:       englebass
> Date:         2010-03-10 13:33:43 -0800 (Wed, 10 Mar 2010)
> New Revision: 47120
>
> Modified:
>  trunk/efreet/src/bin/efreet_desktop_cache_create.c
>
> Modified: trunk/efreet/src/bin/efreet_desktop_cache_create.c
> ===================================================================
> --- trunk/efreet/src/bin/efreet_desktop_cache_create.c  2010-03-10 20:57:06 
> UTC (rev 47119)
> +++ trunk/efreet/src/bin/efreet_desktop_cache_create.c  2010-03-10 21:33:43 
> UTC (rev 47120)
> @@ -8,6 +8,7 @@
>  #include <sys/types.h>
>  #include <sys/stat.h>
>  #include <sys/file.h>
> +#include <sys/mman.h>
>  #include <fcntl.h>
>  #include <unistd.h>
>  #include <errno.h>
> @@ -26,6 +27,12 @@
>  static Eina_Hash *paths = NULL;
>
>  static int
> +strcmplen(const void *data1, const void *data2)
> +{
> +    return strncmp(data1, data2, strlen(data2));
> +}

If you used stringshare, you could use much faster eina_stringshare_len() here.

> +            unsigned int size = *(unsigned int *)p;
> +            p += sizeof(unsigned int);
> +            user_dirs = eina_list_append(user_dirs, strdup(p));

by using eina_stringshare_add_length() here, you could avoid implicit
strlen() inside strdup(), and also get the length for almost 0 cost at
strcmplen...


> +        if (ftruncate(dirsfd, 0) < 0) goto error;

I'd not truncate it, never... truncation is basically useless, and
dangerous for mmaped resources.

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to