Matthew French's [mfrench42@yahoo.co.uk] 65 lines of wisdom included:
> Brian O'Donoghue wrote a code fragment:
> > For(a=0;a > {
> >  some_thing_goes_here();
> >
> >  if(b=strlen(somestring)-4)
> > do_something;
> >
> > };
> 
> Unfortunately strlen is a relatively expensive operation. If you are using
> C++ this is not such a big issue as string.length() can be declared const.
> So long as you do not modify the string object, the compiler can do the
> caching for you.There's a more simple reason as to why strlen shouldn't be used on
the string here, and that's because in future you could actually
change the contents of ``somestring'' within the for loop, and be
left wondering why the number of iterations are not as you expect.Phil.-- 
Irish Linux Users' Group: ilug@linux.ie
http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
List maintainer: listmaster@linux.ie
