Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
String's indexOf method
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Eric Sosman, post: 649114"] Ravi Shankar Nair wrote On 02/06/06 10:19,: It's not clear which of the four different indexOf() methods you're using. Still, no matter which it is, it is probably doing its job nearly as fast as that job can be done. You might get a marginally faster something-or- other in C or C++, but it's unlikely that you'll get a dramatic speedup. Meanwhile, you'd be giving up Java's support of international character sets (less than perfect, but miles ahead of C and C++), Java's protection against out-of-range arguments (especially in C), and so on. You're likely to do better not by looking for a faster indexOf(), but by considering whether indexOf() is being used wisely. Is the program over-using indexOf() when it really ought to be using something else? Is it searching for a one-character String instead of for a single char? Is it always searching from the beginning of the even when it's known that the target doesn't appear among the first thousand characters? Is it searching Strings that are a hundred megabytes in length? Is indexOf() even the right tool -- ought you to be using regular expressions, say? It's been said that the fastest I/O operation is the one you don't perform. "I/O operation" is just a special case of a more general observation, of course. I suggest you re-examine your reasons for using indexOf() so heavily, and consider whether you ought to be using it differently or using something else altogether. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
String's indexOf method
Top