//There is a BufferedReader r
StringBuffer sb = new StringBuffer();
int i;
while ((i = r.read()) != -1)
sb.append((char)i);
What do you think ? will you change it to the more normal
int i;
char[] data = new char[1024];while ((i = r.read(data,0,data.length)) != -1)
sb.append(data);
Edit: Embarassingly the above code is wrong, but the code is only illustrative , reading a character at a time v/s reading chunks of it
Which is more efficient? Which is more 'performant'?
And finally if you read the original code with an additional comment
StringBuffer sb = new StringBuffer();would you even bother?
int i;
// under JIT, testing seems to show this simple loop is as fast
// as any of the alternatives
while ((i = r.read()) != -1)
sb.append((char)i);
Code snippet taken from ImportSupport.java - jakarta-taglibs-standard-1.1.2-src.
No comments:
Post a Comment