mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Cleanup code that was warned by rust-clippy
This commit is contained in:
parent
9c1cb9f61e
commit
81e034885b
9 changed files with 273 additions and 284 deletions
|
@ -161,6 +161,6 @@ impl Cookie {
|
|||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,13 +113,12 @@ impl BasicCORSCache {
|
|||
header_name: &str) -> Option<&'a mut CORSCacheEntry> {
|
||||
self.cleanup();
|
||||
let BasicCORSCache(ref mut buf) = *self;
|
||||
let entry = buf.iter_mut().find(|e| e.origin.scheme == request.origin.scheme &&
|
||||
e.origin.host() == request.origin.host() &&
|
||||
e.origin.port() == request.origin.port() &&
|
||||
e.url == request.destination &&
|
||||
e.credentials == request.credentials &&
|
||||
e.header_or_method.match_header(header_name));
|
||||
entry
|
||||
buf.iter_mut().find(|e| e.origin.scheme == request.origin.scheme &&
|
||||
e.origin.host() == request.origin.host() &&
|
||||
e.origin.port() == request.origin.port() &&
|
||||
e.url == request.destination &&
|
||||
e.credentials == request.credentials &&
|
||||
e.header_or_method.match_header(header_name))
|
||||
}
|
||||
|
||||
fn find_entry_by_method<'a>(&'a mut self, request: &CacheRequestDetails,
|
||||
|
@ -127,13 +126,12 @@ impl BasicCORSCache {
|
|||
// we can take the method from CORSRequest itself
|
||||
self.cleanup();
|
||||
let BasicCORSCache(ref mut buf) = *self;
|
||||
let entry = buf.iter_mut().find(|e| e.origin.scheme == request.origin.scheme &&
|
||||
e.origin.host() == request.origin.host() &&
|
||||
e.origin.port() == request.origin.port() &&
|
||||
e.url == request.destination &&
|
||||
e.credentials == request.credentials &&
|
||||
e.header_or_method.match_method(&method));
|
||||
entry
|
||||
buf.iter_mut().find(|e| e.origin.scheme == request.origin.scheme &&
|
||||
e.origin.host() == request.origin.host() &&
|
||||
e.origin.port() == request.origin.port() &&
|
||||
e.url == request.destination &&
|
||||
e.credentials == request.credentials &&
|
||||
e.header_or_method.match_method(&method))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ enum ReadStatus {
|
|||
fn read_block(reader: &mut File) -> Result<ReadStatus, String> {
|
||||
let mut buf = vec![0; READ_SIZE];
|
||||
match reader.read(&mut buf) {
|
||||
Ok(0) => return Ok(ReadStatus::EOF),
|
||||
Ok(0) => Ok(ReadStatus::EOF),
|
||||
Ok(n) => {
|
||||
buf.truncate(n);
|
||||
Ok(ReadStatus::Partial(buf))
|
||||
|
|
|
@ -419,19 +419,19 @@ impl<R: HttpResponse> StreamedResponse<R> {
|
|||
let result = GzDecoder::new(response);
|
||||
match result {
|
||||
Ok(response_decoding) => {
|
||||
return Ok(StreamedResponse::new(m, Decoder::Gzip(response_decoding)));
|
||||
Ok(StreamedResponse::new(m, Decoder::Gzip(response_decoding)))
|
||||
}
|
||||
Err(err) => {
|
||||
return Err(LoadError::Decoding(m.final_url, err.to_string()));
|
||||
Err(LoadError::Decoding(m.final_url, err.to_string()))
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(Encoding::Deflate) => {
|
||||
let response_decoding = DeflateDecoder::new(response);
|
||||
return Ok(StreamedResponse::new(m, Decoder::Deflate(response_decoding)));
|
||||
Ok(StreamedResponse::new(m, Decoder::Deflate(response_decoding)))
|
||||
}
|
||||
_ => {
|
||||
return Ok(StreamedResponse::new(m, Decoder::Plain(response)));
|
||||
Ok(StreamedResponse::new(m, Decoder::Plain(response)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ pub fn start_sending_sniffed_opt(start_chan: LoadConsumer, mut metadata: Metadat
|
|||
if let Some(ref headers) = metadata.headers {
|
||||
if let Some(ref raw_content_type) = headers.get_raw("content-type") {
|
||||
if raw_content_type.len() > 0 {
|
||||
let ref last_raw_content_type = raw_content_type[raw_content_type.len() - 1];
|
||||
let last_raw_content_type = &raw_content_type[raw_content_type.len() - 1];
|
||||
check_for_apache_bug = apache_bug_predicate(last_raw_content_type)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue