This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Bryce McKinlay wrote:
Here's my BufferedReader and InputStreamReader improvements. Perhaps you would like to bake these versions off against your modifications. In the case of BufferedReader the new code is a lot simpler as well as potentially more efficient, since it gets rid of all the special-case checks for "\r" at the end of each line.
Sorry for coming late into this BufferedReader discussion. Since according to the CVS you wrote the huge chunk of the \r\n handling code, it would be interesting to hear why it's possible to get rid of it now.
/** Read more data into the buffer, updating pos and limit appropriately,
* and taking mark and markLimit into account. Assumes pos==limit initially.
* Return true if chars were added to the buffer, or false on EOF. */
private boolean refill() throws IOException
I think this function could yield a significant perfomance boost if we used a circular buffer in the BufferedReader. Then the arraycopys to shuffle bytes around to the beginning may not be necessary.
[snip]public String readLine() throws IOException {// Consume the line termination character(s).
I think that's a bad idea, because it can cause deadlocks. See http://developer.apple.com/technotes/tn/tn1157.html . Citing from it :
"Fixing the server
If you happen to be developing the server as well, and can make changes to its code, then there's an even better fix you can make on the server side instead of changing the client. In the previous section, I described how the server blocks waiting for a character to follow the CR so it can tell whether it's an LF or not. A more intelligent way to handle nonstandard line breaks is for the server to process the input line immediately once it receives the CR, but to set a flag that indicates that if the next character received is an LF it should be ignored.
This way the server will not block after it receives the CR, will process the command and return a response, and the client code will receive the response and continue running. No deadlock."
Attachment:
Reader.patch.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |