mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Avoid virtual calls when loading files.
This commit is contained in:
parent
ebf5a70b51
commit
6881776d81
1 changed files with 3 additions and 3 deletions
|
@ -8,8 +8,8 @@ use mime_classifier::MIMEClassifier;
|
|||
use resource_task::{start_sending, start_sending_sniffed};
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
use std::io;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::mpsc::Sender;
|
||||
|
@ -22,7 +22,7 @@ enum ReadStatus {
|
|||
EOF,
|
||||
}
|
||||
|
||||
fn read_block(reader: &mut io::Read) -> Result<ReadStatus, String> {
|
||||
fn read_block(reader: &mut File) -> Result<ReadStatus, String> {
|
||||
let mut buf = vec![0; READ_SIZE];
|
||||
match reader.read(buf.as_mut_slice()) {
|
||||
Ok(0) => return Ok(ReadStatus::EOF),
|
||||
|
@ -34,7 +34,7 @@ fn read_block(reader: &mut io::Read) -> Result<ReadStatus, String> {
|
|||
}
|
||||
}
|
||||
|
||||
fn read_all(reader: &mut io::Read, progress_chan: &Sender<ProgressMsg>)
|
||||
fn read_all(reader: &mut File, progress_chan: &Sender<ProgressMsg>)
|
||||
-> Result<(), String> {
|
||||
loop {
|
||||
match try!(read_block(reader)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue