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.
> 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.
> 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 :)
> 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. :)
> 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 (東京 日本)
-------------------------------------------------------------------------
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