You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Jon Smirl <jo...@mediaone.net> on 2000/06/15 07:00:29 UTC

Xalan-c: indexOf(), lastIndexOf()

The Java support routines indexOf(), lastIndexOf() in DOMStringHelper.cpp
returns the length of the string when the character is not found. The Java
spec says it should return -1. Is this by designed or a bug? Returning the
length makes me need to do a strlen() to tell if the character wasn't found.

Re: Xalan-c: indexOf(), lastIndexOf()

Posted by Jon Smirl <jo...@mediaone.net>.
Another thought, returning length instead of -1 means your compiled code
will be more inefficient. -1 is a constant and length is a variable. It is
much easier for the compiler to compare and optimize with a constant.

Jon Smirl
jonsmirl@mediaone.net