On Sun, 12 Aug 2007 03:47:49 -0400 Youness Alaoui
<[EMAIL PROTECTED]> babbled:

> On Sun, Aug 12, 2007 at 03:16:55PM +0900, Carsten Haitzler wrote:
> > On Sun, 12 Aug 2007 02:09:46 -0400 Youness Alaoui
> > <[EMAIL PROTECTED]> babbled:
> > 
> > > Hi (first mail on the mailing list),
> > > 
> > > Wouldn't it be more efficient if you only lowered the extension instead of
> > > the whole file. I know it's almost nothing cpu-wise, but it would still be
> > > useless to waste some small cpu cycles on this.
> > 
> > it will make almost no difference - i need to make a copy anyway and that is
> > the biggest expense already. in fact while making the copy i should lower
> > it so it'd be for free.
> > 
> 
> Yeah, I know almost no difference, but if we can "see" that it can be 
> done better, then why not do it. A
> small 'no difference' here and there, and have that function called 
> thousands of times, and the 'no
> difference' becomes a difference.
> 
> > > looking for the first '.' andd then lowering anything after it would be
> > 
> > to find the first . u need to read all of the string from the start anyway.
> > so you still have the read cost - and compare to '.' cost.
> > 
> 
> yeah, the read cost, we can't cut it, there's always a 'bare minimum' which
> you can't do without.
> 
> > > better, no ? This could also be used for the strcpy, if you only copy
> > > inside 'sl' the chars that come after the first '.', it might save some
> > > cpu cycles + memory space.
> > 
> > sure - it makes the code more complex. i'd save a few cycles. but in the
> > end - you won't see a difference. i'd love to see you come up with a way to
> > measure any speedup there :)
> > 
> 
> lol, I don't think there's a way to measure the speedup. Plus, I'm more of a
> designer than an 'optimizer',
> you're the one with all that optimization knowledge AFAIK :)
> But yes, I do think that a copy of ".zip" would be faster than a copy of 
> "/my/huge/path/and_big_filename.zip".. + less
> +memory used.
> and a few hundred thousands of them will probably make a difference.

actually its only ever filename - not full path, so it's
"and_a_big_filename.zip" only :)

> About code complexity, I don't think it is though. Maybe depends on the
> person, especially since this is
> really a small set of lines, I wouldn't consider it 'complex'.

i already fixed this now - but i took it a few steps further - there were much
worse things floating about in that code.

> > > I would suggest this (untested) patch instead, as it would be more
> > > efficient : const char *efreet_mime_globs_type_get(const char *file)
> > > {
> > >      Efreet_Mime_Glob *g;
> > > -    char *s;
> > > +    char *s, *dot;
> > >      const char *ext, *mime;
> > > 
> > >      /*
> > >       * Check in the extension hash for the type
> > >       */
> > > -   ext = strchr(file,'.');
> > > +   dot = strchr(file,'.');
> > > +   ext = alloca(strlen(dot) + 1);
> > > +   strcpy(ext, dot);
> > > +   for (s = ext; *s; s++) *s = tolower(*s);
> > > 
> > >     while(ext)
> > >     {
> > >          ++ext;
> > > 
> > > 
> > > 
> > > What do you think?
> > > KaKaRoTo
> > 
> > if you want to get nitty about efficiency - you have a strcpy there - remove
> > that and copy the extension onwards as part of the for loop and tolower()
> > ing. :)
> > 
> 
> haha, yeah, I should have thought about that :p
> You're probably right.. why not do it like that then? ;)

i just did :)

> Anyways, just throwing my 2cents in here, but it's not a difficult problem,
> so let's not debate too long on this.
> + I had a good reason to write and say hi to everyone :p

indeed - and you are very welcome - you did prompt me to do it right - all the
way, and i found some nasty memory leaks and much worse things there in terms
of optimisation - fixed now :)

> KaKaRoTo
> 
> 
> > > On Sun, Aug 12, 2007 at 10:37:22AM +0900, Carsten Haitzler wrote:
> > > > On Sat, 11 Aug 2007 18:24:15 +0200 Peter Wehrfritz
> > > > <[EMAIL PROTECTED]> babbled:
> > > > 
> > > > yes - as it will only be comparing a series of extenstions after the
> > > > first "." the lowering of the chars before that is harmless. this
> > > > assumes the extension is also stored in lower case too (which seems to
> > > > be the case).
> > > > 
> > > > 
> > > > so you have
> > > > 
> > > > "BigSmellyFish.JPG" -> "bigsmellyfish.jpg"
> > > > then u lookup "jpg"
> > > > 
> > > > if it was
> > > > 
> > > > "BigSmellyFish.tar.GZ" -> "bigsmellyfish.tar.gz"
> > > > then you lookup "tar.gz" and tyhen if that fails, look up "gz".
> > > > 
> > > > > Enlightenment CVS schrieb:
> > > > > > Enlightenment CVS committal
> > > > > >
> > > > > > Author  : raster
> > > > > > Project : e17
> > > > > > Module  : libs/efreet
> > > > > >
> > > > > > Dir     : e17/libs/efreet/src/lib
> > > > > >
> > > > > >
> > > > > > Modified Files:
> > > > > >     efreet_mime.c 
> > > > > >
> > > > > >
> > > > > > Log Message:
> > > > > >
> > > > > >
> > > > > > externsion checks should be case-insensitve.
> > > > > >
> > > > > > ===================================================================
> > > > > > RCS file: /cvs/e/e17/libs/efreet/src/lib/efreet_mime.c,v
> > > > > > retrieving revision 1.24
> > > > > > retrieving revision 1.25
> > > > > > diff -u -3 -r1.24 -r1.25
> > > > > > --- efreet_mime.c   26 Jul 2007 11:30:10 -0000      1.24
> > > > > > +++ efreet_mime.c   11 Aug 2007 13:20:16 -0000      1.25
> > > > > > @@ -258,23 +258,26 @@
> > > > > >  const char *efreet_mime_globs_type_get(const char *file)
> > > > > >  {
> > > > > >      Efreet_Mime_Glob *g;
> > > > > > -    char *s;
> > > > > > +    char *s, *sl;
> > > > > >      const char *ext, *mime;
> > > > > > -    
> > > > > > +
> > > > > >      /*
> > > > > >       * Check in the extension hash for the type
> > > > > >       */
> > > > > > -    ext = strchr(file,'.');
> > > > > > -    while(ext)
> > > > > > -    {
> > > > > > +   sl = alloca(strlen(file) + 1);
> > > > > > +   strcpy(sl, file);
> > > > > > +   for (s = sl; *s; s++) *s = tolower(*s);
> > > > > > +   ext = strchr(sl,'.');
> > > > > > +   while(ext)
> > > > > > +     {
> > > > > >          ++ext;
> > > > > >   
> > > > > Are you sure that you want to lower the whole filename?
> > > > > 
> > > > > -------------------------------------------------------------------------
> > > > > This SF.net email is sponsored by: Splunk Inc.
> > > > > Still grepping through log files to find problems?  Stop.
> > > > > Now Search log events and configuration files using AJAX and a
> > > > > browser. Download your FREE copy of Splunk now >>
> > > > > http://get.splunk.com/ _______________________________________________
> > > > > enlightenment-devel mailing list
> > > > > [email protected]
> > > > > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> > > > > 
> > > > 
> > > > 
> > > > -- 
> > > > ------------- Codito, ergo sum - "I code, therefore I am" --------------
> > > > The Rasterman (Carsten Haitzler)    [EMAIL PROTECTED]
> > > > 裸好多
> > > > Tokyo, Japan (東京 日本)
> > > > 
> > > > -------------------------------------------------------------------------
> > > > This SF.net email is sponsored by: Splunk Inc.
> > > > Still grepping through log files to find problems?  Stop.
> > > > Now Search log events and configuration files using AJAX and a browser.
> > > > Download your FREE copy of Splunk now >>  http://get.splunk.com/
> > > > _______________________________________________
> > > > enlightenment-devel mailing list
> > > > [email protected]
> > > > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> > > 
> > > -------------------------------------------------------------------------
> > > This SF.net email is sponsored by: Splunk Inc.
> > > Still grepping through log files to find problems?  Stop.
> > > Now Search log events and configuration files using AJAX and a browser.
> > > Download your FREE copy of Splunk now >>  http://get.splunk.com/
> > > _______________________________________________
> > > enlightenment-devel mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> > 
> > 
> > -- 
> > ------------- Codito, ergo sum - "I code, therefore I am" --------------
> > The Rasterman (Carsten Haitzler)    [EMAIL PROTECTED]
> > 裸好多
> > Tokyo, Japan (東京 日本)
> 


-- 
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler)    [EMAIL PROTECTED]
裸好多
Tokyo, Japan (東京 日本)

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to