From: Ricardo P. <ri...@us...> - 2002-02-04 13:14:47
|
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 ri...@us... Murcia. Espa=F1a. |