sub-optimal IO#read after IO#getc
---------------------------------

                 Key: JRUBY-3721
                 URL: http://jira.codehaus.org/browse/JRUBY-3721
             Project: JRuby
          Issue Type: Improvement
    Affects Versions: JRuby 1.3RC2
            Reporter: Wayne Meissner
            Assignee: Thomas E Enebo



When given a code snippet like:
{code}
f = File.new("/tmp/test.rb", "r")
first = f.getc
rest = f.read
{code}

The getc will fill the ChannelStream buffer, then copy one char out.  The 
following read calls ChannelStream#readall(), which invalidates the buffer, 
then re-reads the contents of the file.

Instead of invalidating the buffer and re-reading, readall() could make use of 
the buffered data, and avoid a couple of seeks and a read.

This might make a difference for small files, if a similar read sequence is 
used.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to