Actually, String.substring() is blazingly fast. The only thing that would be faster still is to avoid object creation completely by keeping track of the substring start and end positions in variables.Originally posted by saravanan s:
I have to extract a substring from a large string.So i am using substring method. But it is taking lot of time.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Actually, String.substring() is blazingly fast. The only thing that would be faster still is to avoid object creation completely by keeping track of the substring start and end positions in variables.Originally posted by Peter den Haan:
Originally posted by saravanan s:
[b]I have to extract a substring from a large string.So i am using substring method. But it is taking lot of time.
Are you sure it's this line that takes so much time? Sure as in "profiler"? Because there's nothing here that takes an awful amount of time, except possibly the toString conversion of "value" and "endelements[k]" if they are objects with complex or inefficient toString() implementations.Originally posted by saravanan s:
tempStr = tempStr.append(rLine.substring(n, ilength)).append(value).append(endelements[k]);
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Well, I don't know either (as in "profiler" ) but I can spot a few things that are likely to be far more important than the line of code you showed. I hope others will be able to shed more light.Originally posted by saravanan s:
This is my code.I don't know what is wrong with this.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Don't get me started about those stupid light bulbs. |