On Wed, Oct 17, 2012 at 7:24 AM, Enlightenment SVN <
no-re...@enlightenment.org> wrote:

> Log:
> add tmpstr to efl eina tree... this is for the future so not going
>   into eina tree.
>

Weird, I'm missing the use case for this, as it's very much like
stringshare, except it's not unique then it does not incur the hash and
lookup.

Is that the idea, to avoid going to stringshare and its cost?

>From the name and docs, i initially thought it would be using thread local
storage to create the strings there, thus avoiding locks. Why not do that?

Initially I also thought it would be automatically cleanup, or a big buffer
that would be set per-thread and reused, hence the name. But then I saw one
example with 2 tmpstr and it would be impossible.

This seems like a "string", not "tmpstr". If that's the case, what about if
we call it Eina_Str? It could match well with eina_str.h code.

Last but not least, please keep the size and offer a strlen()... very
common use that could be made O(1) :-)

as a small review, instead of:

   strcpy(s->str, str);

use memcpy() as you know the size, avoid copy with per-byte lookup of \0.

Instead of:

struct _Str
{
   Str *next;
   char *str;
};

Use:

struct _Str
{
   Str *next;
   char str[];
};

then you can avoid the pointer math (and very likely the pointer memory
usage).

Less safe than the current code, but expected by stringshare is if you give
it really a Eina_Tmpstr you can avoid the list lookup and just do pointer
math to get the node from string:

   Str *node = input_str - offsetof(Str, str);

Regards,

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to