[Bug c++/38986] comparing lengths of 2 strings reads through both strings completely

2009-02-01 Thread falk at debian dot org
--- Comment #3 from falk at debian dot org 2009-02-01 10:50 --- The main problem is that just replacing the code by the below loop won't necessarily give a speedup. strlen is usually implemented in highly efficient and platform-specific assembly that treats several bytes at a time. I don

[Bug c++/38986] comparing lengths of 2 strings reads through both strings completely

2009-01-30 Thread esigra at gmail dot com
--- Comment #2 from esigra at gmail dot com 2009-01-30 16:12 --- GCC already understands the semantics of strlen. If one of the operands to "<" is a constant and the other is strlen, it is optimized (such as "strlen(str) >= 1). It just seems like the case with strlen on both sides is mis

[Bug c++/38986] comparing lengths of 2 strings reads through both strings completely

2009-01-30 Thread bangerth at gmail dot com
--- Comment #1 from bangerth at gmail dot com 2009-01-30 15:13 --- Yes, I think this would be an optimizing compiler could potentially perform. At the same time I think you are expecting too much from the compiler: it would have to have a semantic understanding of what the strlen functio