On Mon, 2002-02-04 at 23:19, Jeff Epler wrote:
> I'm arguing that WHATEVER WAY you want to code "string is empty", you
> would do better to enclose it in a macro that shows the programmer
> what is going on.
yep teuf and me are doing this just now...
> I'll say it again -- premature optimization is the root of all evil.
> And this sure smells like an example.
oki, i snipped all that stuff off...
first of all the main intention of my patch wasnt SPEED. it was to avoid
using strlen to measure the size of the string at all. your effort of
measure the time in all glory. but you missed the point.
a) why should i go through a whole librarycall to measure the size of a
string if i only need to figure out if it points to NULL or '\0'
b) speed oki as you measured. not to mention that it behaves differently
on a lot of other factors e.g. precaching of code etc.
c) as you saw on all my mails i know why i sent in this patch and
explained it several times now. i also checked with gcc -O2 and
it still jumps into the libcall.
well thats all i have to say. i got a lot of positive feedback either
private or on irc. today we may save some cycles here. but tommorrow it
could be on another place within galeon. why not following good coding
style ?
--
Name....: Ali Akcaagac
Status..: Student Of Computer & Economic Science
E-Mail..: mailto:ali.akcaagac@...
http://www.....: http://www.fh-wilhelmshaven.de/~akcaagaa

Here is a patch which fixes those issues, apart from the multiple
definitions of the macro (I couldn't find a header file which is
included in all source files). I also removed the strnempty macro since
strnempty(s) == !strempty(s). And I modified the patch to remove the
unnecessary checks because the macro is NULL-safe.
Ali Akcaagac reviewed this patch, if more people could have a look at
it, it would be nice. And these strlen(s)==0 checks should really be
removed, it's as ugly as using g_list_length to test if a list is
empty...
Cheers,
Christophe
Le 2002.02.04 22:09, Lionel Elie Mamane a écrit :
> On Mon, Feb 04, 2002 at 05:25:18PM +0100, Ali Akcaagac wrote:
>
> > > #define strempty(s) ((s==NULL) ? 1 : (*s!= '\0'))
> > > #define strnempty(s) ((s==NULL) ? 0 : (*s== '\0'))
>
> > thats almost perfect. nothing from my side to add.
>
> Really? I see at least two important issues!
>
> Look hard at it: I mixed up empty and non-empty! If s is empty, then
> *s _is_ '\0'!!
>
> So it should read:
> #define strempty(s) ((s==NULL) ? 1 : (*s == '\0'))
> #define strnempty(s) ((s==NULL) ? 0 : (*s != '\0'))
>
> Second error: there _really_ should be parentheses around the s'es:
>
> #define strempty(s) (((s)==NULL) ? 1 : (*(s) == '\0'))
> #define strnempty(s) (((s)==NULL) ? 0 : (*(s) != '\0'))
>
> I saw your patch, too. Why do you define those macros in several
> places? (Yes, I saw that you inversed the use of strempty and
> strnempty in your code, but then the NULL case is false. Which matters
> only in galeon/src/xbel.c)
>
> P.S.: I checked. strlen is not NULL-safe. So as you are
> micro-optimizing anyway, you may want to take the straight versions,
> except where sstrlen was used ;-)
>
> --
> Lionel Elie Mamane
>

On Mon, 2002-02-04 at 22:09, Lionel Elie Mamane wrote:
> P.S.: I checked. strlen is not NULL-safe. So as you are
> micro-optimizing anyway, you may want to take the straight versions,
> except where sstrlen was used ;-)
yes, teuf pointed me about this stuff on irc already. as i said i am no
friend of macros and yes i needed to define that stuff in 2 headerfiles
one in src/* and one in mozilla/* because gcc 3.0.3 complains about it
i was noticed that it behaves exactly oposite with gcc 2.95.x teuf is
hacking that one up now anyways thank you for your comments:
a) i still think the nonmacro version is better
b) the macro version could be used too, lets wait until teuf works
that stuff over
c) chances are good that this all was a waste of time :)
--
Name....: Ali Akcaagac
Status..: Student Of Computer & Economic Science
E-Mail..: mailto:ali.akcaagac@...
http://www.....: http://www.fh-wilhelmshaven.de/~akcaagaa

On Mon, Feb 04, 2002 at 05:25:18PM +0100, Ali Akcaagac wrote:
> > #define strempty(s) ((s=3D=3DNULL) ? 1 : (*s!=3D '\0'))
> > #define strnempty(s) ((s=3D=3DNULL) ? 0 : (*s=3D=3D '\0'))
> thats almost perfect. nothing from my side to add.
Really? I see at least two important issues!
Look hard at it: I mixed up empty and non-empty! If s is empty, then
*s _is_ '\0'!!
So it should read:
#define strempty(s) ((s=3D=3DNULL) ? 1 : (*s =3D=3D '\0'))
#define strnempty(s) ((s=3D=3DNULL) ? 0 : (*s !=3D '\0'))
Second error: there _really_ should be parentheses around the s'es:
#define strempty(s) (((s)=3D=3DNULL) ? 1 : (*(s) =3D=3D '\0'))
#define strnempty(s) (((s)=3D=3DNULL) ? 0 : (*(s) !=3D '\0'))
I saw your patch, too. Why do you define those macros in several
places? (Yes, I saw that you inversed the use of strempty and
strnempty in your code, but then the NULL case is false. Which matters
only in galeon/src/xbel.c)
P.S.: I checked. strlen is not NULL-safe. So as you are
micro-optimizing anyway, you may want to take the straight versions,
except where sstrlen was used ;-)
--=20
Lionel Elie Mamane

Thanks for the answer,
but what string should I use for internet explorer 5.5 say?
Thanks in advance
On Mon, 2002-02-04 at 10:31, Topher wrote:
> > just a suggestion that could be helpful, I hope.
> >
> > A lot of sites out there will complain that they only support iexplore.
> >
> > So i think it would be nice to be able like opera to masquerade as
> > iexplore and bypass the stupid warning. Most of the time, there are no
> > problems whatsoever with the site and the browser.
>
> http://galeon.sourceforge.net/support/answers.php?faq=user-agent
>
> How can I change the User Agent string that galeon uses?
>
> This feature is already implemented. It is not in the UI because there was
> a mozilla bug that made galeon to crash at startup with some strings.
>
> You can set the user agent from the command line using GConf:
>
> 1. To get the current user agent:
>
> gconftool -g /apps/galeon/Advanced/Network/user_agent
>
> 2. To set the user agent to XXX:
>
> gconftool -s /apps/galeon/Advanced/Network/user_agent --type=string "XXX"
>
> 3. To restore the default user agent:
>
> gconftool -s /apps/galeon/Advanced/Network/user_agent --type=string
> default
>
>
>
> Topher
> Manager of Internet Services
> Cornerstone Broadcasting
> Cornerstone University

On Mon, 4 Feb 2002, Ben Pearre wrote:
> > Usually, I send a 'nice' mail to those site-owners, telling them they lost
> > a customer/client/visitor/whatever. That way, they understand (or have at
> > least a chance to) how they're feeding the beast that M$ is...
>
> Sort of agreed. So, how about a feature that will detect such warnings
> and automatically send a nastygram to the web admin?
i still remember, 5 years ago, when i was at anti-ms@...
people are helping each other to draft email template to be sended to
webmaster who are bias to IE. The draft is very formal, polite.
Why dont we draft one, telling how important to be web standard
compliance. no need to mention galeon. or may be just an example.
--
Hasbullah Bin Pit (sebol)
Fail .signature ini mengandungi enam belas aksara 'a' dan lapan aksara 'i'

> But won't that make those sites even more iexplore-submissive? After all,
> for them it seems like you (and everybody else) is indeed using iexplore,
> which won't really improve it...
>
> Usually, I send a 'nice' mail to those site-owners, telling them they lost
> a customer/client/visitor/whatever. That way, they understand (or have at
> least a chance to) how they're feeding the beast that M$ is...
Sort of agreed. So, how about a feature that will detect such warnings
and automatically send a nastygram to the web admin?
:)
--
bwpearre@... http://hebb.mit.edu/~ben

On Mon, 2002-02-04 at 12:42, Ali Akcaagac wrote:
> if(strlen(blah) == 0) and
> if(strlen(blah) > 0)
>
> becomes
>
> if(*blah == '\0') and
> if(*blah != '\0')
ok here the 'MACRO' version of that patch. i am not sure if this is as
it should be since i don't like using macros. i still recommend applying
the other one please apply and check. i am running galeon fine with this
patch (until now). oki someone wants to verify this too.
comments, ideas and suggestions ?
--
Name....: Ali Akcaagac
Status..: Student Of Computer & Economic Science
E-Mail..: mailto:ali.akcaagac@...
http://www.....: http://www.fh-wilhelmshaven.de/~akcaagaa

On Mon, Feb 04, 2002 at 04:54:42PM +0100, Ali Akcaagac wrote:
> > Last, I wonder if neither form is most expressive of the true
> > operation. Let the real implementation be hidden in a macro,
> no. you dont get the point.
I think he meant this:
#define strempty(s) (*s !=3D '\0')
#define strnempty(s) (*s =3D=3D '\0')
then in the code, replace
if (strlen(foo) =3D=3D 0)
by
if (strempty(foo))
and
if (strlen(foo) > 0)
by
if (strnempty(foo))
which will give exactly the same compiled code, but more readability.
By the way, a bug your patch might introduce is if the tested string
is in fact a NULL pointer... Didn't check it, but maybe strlen is
null-safe (and returns 0), so the macro definition should be:
#define strempty(s) ((s=3D=3DNULL) ? 1 : (*s!=3D '\0'))
#define strnempty(s) ((s=3D=3DNULL) ? 0 : (*s=3D=3D '\0'))
--=20
Lionel

On Mon, 2002-02-04 at 16:30, Jeff Epler wrote:
> Second, if you're micro-optimizing, maybe there's some compiler that
> produces better code for
> if (*p)
> than
> if (*p != 0)
maybe you look again in the patch i sent in and maybe you want to do
some own tests with your own compiler. i hope you understand what i am
talking about. i got a few replies already but it seem to be that people
dont understand what i want to point out because of no assembler
experience.
> Last, I wonder if neither form is most expressive of the true
> operation. Let the real implementation be hidden in a macro,
> strempty/strnonempty if you want to ignore the reservation of all
> identifiers starting with "str". Isn't
> strempty(s)
> better than any of
> !*s
> !strlen(s)
> strlen(s) == 0
> s[0] == '\0'
> regardless of the efficiency?
no. you dont get the point. you need to read my previous patch once
again.
a system call does this:
- it jumps into the function call - jumping costs time
- the function does its own operation - doing this costs time
- the function call must return - returning costs time
one example with mc680x0 assembly language:
loop:
moveq #-1,d0 <--- 0xFFFFFFFF
.loop:
bsr.w strlen <--- the bsr.w costs time some unknown
amount of clockcycles
dbra d0,.loop
rts
strlen:
.... <--- strlen whatever it does..
counting up to get the value
costs time
....
....
rts <--- returning from sub costs time too
now it loops there 0xFFFFFFFF times you can count yourself how many
cycles you gonna waste by doing this. well in galeon we dont have to
cycle so many times but there are some embedded loops that are. now what
i do is i skip all this. no need to use a systemcall (oki librarycall)
at all, check if the string has a nullbyte or not and voila. its faster
usually modern compilers do this but under certain circumstances. as my
TEST file described in the previous mail it doesnt do
> And how much time will it waste for each user if a bug is introduced by
> changing this code? More time, I'll wager, than they ever spent waiting
> for the strlen() calls you're propsing to remove took.
what bug ? there are no bugs its a simple easy to understand convert.
but i am not only timeconcerned here. i am concerned about these things
a) speed (sure time)
b) codesize
c) not to abuse strlens for plain check if the string is emty or not.
here some triva for you for speed issues:
loop: loop:
moveq #0,d0 moveq #0,d1
moveq #0,d1
move.b #-1,d0 addq.l #1,d1
.loop: addq.l #1,d1
addq.l #1,d1 addq.l #1,d1
dbra d0,.loop ... repeat 255 times
rts rts
guess which one is faster. neverthless this example is quite stupid. but
i am not usually talking about speed now i am talking for a better style
you change nothing that cause errors or something. its a clear selfex-
plaining patch that only needs to be reviewed and applied.
--
Name....: Ali Akcaagac
Status..: Student Of Computer & Economic Science
E-Mail..: mailto:ali.akcaagac@...
http://www.....: http://www.fh-wilhelmshaven.de/~akcaagaa

On Mon, 2002-02-04 at 16:25, Hassan Aurag wrote:
> Hi,
>
>
> just a suggestion that could be helpful, I hope.
>
> A lot of sites out there will complain that they only support iexplore.
>
> So i think it would be nice to be able like opera to masquerade as
> iexplore and bypass the stupid warning. Most of the time, there are no
> problems whatsoever with the site and the browser.
>
But won't that make those sites even more iexplore-submissive? After all,
for them it seems like you (and everybody else) is indeed using iexplore,
which won't really improve it...
Usually, I send a 'nice' mail to those site-owners, telling them they lost
a customer/client/visitor/whatever. That way, they understand (or have at
least a chance to) how they're feeding the beast that M$ is...
Just my opinion...
Kind regards,
wouter
>
>
>
>
> _______________________________________________
> Galeon-devel mailing list
> Galeon-devel@...
> https://lists.sourceforge.net/lists/listinfo/galeon-devel

> just a suggestion that could be helpful, I hope.
>
> A lot of sites out there will complain that they only support iexplore.
>
> So i think it would be nice to be able like opera to masquerade as
> iexplore and bypass the stupid warning. Most of the time, there are no
> problems whatsoever with the site and the browser.
http://galeon.sourceforge.net/support/answers.php?faq=user-agent
How can I change the User Agent string that galeon uses?
This feature is already implemented. It is not in the UI because there was
a mozilla bug that made galeon to crash at startup with some strings.
You can set the user agent from the command line using GConf:
1. To get the current user agent:
gconftool -g /apps/galeon/Advanced/Network/user_agent
2. To set the user agent to XXX:
gconftool -s /apps/galeon/Advanced/Network/user_agent --type=string "XXX"
3. To restore the default user agent:
gconftool -s /apps/galeon/Advanced/Network/user_agent --type=string
default
Topher
Manager of Internet Services
Cornerstone Broadcasting
Cornerstone University

Hi,
just a suggestion that could be helpful, I hope.
A lot of sites out there will complain that they only support iexplore.
So i think it would be nice to be able like opera to masquerade as
iexplore and bypass the stupid warning. Most of the time, there are no
problems whatsoever with the site and the browser.

On Mon, 2002-02-04 at 14:54, Alfons Hoogervorst wrote:
> Like the original poster said: does it matter in Galeon? Because you just
> proved you can make a very fast loop. ;-)
>
> (I like your code because of it's clarity and obviousness though, but
> that's an opinion, which differs among C programmers.)
was a typo - read the mail that i posted some mins ago. often it is
difficult writing a mail and concentrate on code too. but at least you
know what i wanted to point out. for me, i don't care much if you commit
this to cvs or not. but for me it's plain stupid using strlen to check
if the string is empty or not.
--
Name....: Ali Akcaagac
Status..: Student Of Computer & Economic Science
E-Mail..: mailto:ali.akcaagac@...
http://www.....: http://www.fh-wilhelmshaven.de/~akcaagaa

At 02:32 PM 2/4/02 +0100, Ali Akcaagac wrote:
> > Even with no inlinig at all, you are talking here about some few cycles.
> > I prefer readable code rather than a few microsenconds less. This kind
> > of optimization only makes sense inside speed critical loops, otherwise
> > you can't notice it (even in slow computers). Maybe the autocompleion
> > related changes make some sense, but I think it's fast enough already.
>
>for(i=0;i>100000;i++) {
> above code unoptimized
>)
>
>vs
>
>for(i=0;i>100000;i++) {
> above code OPTIMIZED
>)
Like the original poster said: does it matter in Galeon? Because you just
proved you can make a very fast loop. ;-)
(I like your code because of it's clarity and obviousness though, but
that's an opinion, which differs among C programmers.)
Bye.

El lun, 04-02-2002 a las 12:42, Ali Akcaagac escribi=F3:
> hello,
>=20
> i went through galeon head this morning and detected a lot of
>=20
> if(strlen(blah) =3D=3D 0) and
> if(strlen(blah) > 0)
>=20
> calls. i for my own think this shouldnt be done this way. i talked in
> the #gnome channel about this and got a couple of replies that i was
> accepting. e.g. that a good compiler does this inline conversion on its
> own etc. but my theory is different. e.g if you call up strlen then what
> exactly will happen ?
[...]
>=20
>=20
> the above code results in this file after doing 'gcc test.c -S test.s'
If you use gcc -O2 you get strlen inlined:
.file "test.c"
.version "01.01"
gcc2_compiled.:
.section .rodata.str1.1,"ams",@progbits,1
.LC0:
.string "this is a test"
.text
.align 4
.globl main
.type main,@function
main:
pushl %ebp
xorl %eax, %eax
movl %esp, %ebp
cld
pushl %edi
movl $-1, %ecx
movl $.LC0, %edi
repnz
scasb
cmpl $-2, %ecx
movl (%esp), %edi
leave
ret
.Lfe1:
.size main,.Lfe1-main
.ident "GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)"
>=20
> here the patch for today's CVS... have fun... btw please check it up i
> took a lot of care but it may be possible that i fucked up something.
> but all in all this is a good patch IMO. because galeon has a lot of
> these strlen null and strlen not null checks.
>=20
Even with no inlinig at all, you are talking here about some few cycles.
I prefer readable code rather than a few microsenconds less. This kind
of optimization only makes sense inside speed critical loops, otherwise
you can't notice it (even in slow computers). Maybe the autocompleion
related changes make some sense, but I think it's fast enough already.
(I don't mind if this patch is applied, but I don't see the need for it)
--=20
Ricardo Fern=E1ndez Pascual
ric@...
Murcia. Espa=F1a.

hello,
i went through galeon head this morning and detected a lot of
if(strlen(blah) == 0) and
if(strlen(blah) > 0)
calls. i for my own think this shouldnt be done this way. i talked in
the #gnome channel about this and got a couple of replies that i was
accepting. e.g. that a good compiler does this inline conversion on its
own etc. but my theory is different. e.g if you call up strlen then what
exactly will happen ?
a) there is a call to strlen
b) strlen takes action (a nonvisible action takes place)
c) return from call
jumping and returning itself costs a lot of clockcycles. in heavy
timeconsuming situations this is plain sick. you can simplify this stuff
drastically and it ends up in faster code.
if(strlen(blah) == 0) and
if(strlen(blah) > 0)
becomes
if(*blah == '\0') and
if(*blah != '\0')
here the patch for todays CVS (checked out some minutes ago) i applied
this patch and compiled galeon without errors and using it without any
problems. galeon should be a tad shorter in codesize and a lot of times
faster.
and here my confirmation that this what i am trying to point out is
correct. please read this before you start a discussion about good
style, automatic inline conversion of the compiler etc.
;-------------------------------------------------------------
#include <stdio.h>
int main(int argc,char **argv)
{
char *test="this is a test";
if (strlen(test) == 0)
return;
if (*test == '\0')
return;
}
;-------------------------------------------------------------
the above code results in this file after doing 'gcc test.c -S test.s'
;-------------------------------------------------------------
.file "test.c"
.section .rodata
.LC0:
.string "this is a test"
.text
.align 16
.globl main
.type main,@function
main:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
movl $.LC0, -4(%ebp)
subl $12, %esp
pushl -4(%ebp)
call strlen
addl $16, %esp
testl %eax, %eax
jne .L2
jmp .L1
.p2align 4,,7
.L2:
movl -4(%ebp), %eax
cmpb $0, (%eax)
jne .L3
jmp .L1
.p2align 4,,7
.L3:
.L1:
movl %ebp, %esp
popl %ebp
ret
.Lfe1:
.size main,.Lfe1-main
.ident "GCC: (GNU) 3.0.3"
;-------------------------------------------------------------
as you see the first if does things between .L2-main and the other
between .L3-.L2 from assembly point of view this is quite fast since you
dont need to go through all the processor mnemonics, not to mention the
need to jump in a subroutine and return from it.
here the patch for today's CVS... have fun... btw please check it up i
took a lot of care but it may be possible that i fucked up something.
but all in all this is a good patch IMO. because galeon has a lot of
these strlen null and strlen not null checks.
--
Name....: Ali Akcaagac
Status..: Student Of Computer & Economic Science
E-Mail..: mailto:ali.akcaagac@...
http://www.....: http://www.fh-wilhelmshaven.de/~akcaagaa

Op Mon, 4 Feb 2002 09:43:49 +0000
krabbelde Andy Jeffries <andy@...>:
>
> I don't know if this is a bug with Mozilla or Galeon, but if you submit
> a form with a file upload field on it, without uploading a file, Galeon
> seems to hang!
>
> If anyone wants me to put a test page up that demonstrates this, let
> me know.
>
> Cheers,
This is a Mozilla bug.
http://bugzilla.mozilla.org/show_bug.cgi?id=116494
it seems that it is fixed, so 0.9.8 will be ok, i hope
--
Wilbert Berendsen (http://www.xs4all.nl/~wbsoft/)