Skip to content

Commit

Permalink
Fix warnings: Use Vec.extend_from_slice instead of Vec.push_all
Browse files Browse the repository at this point in the history
  • Loading branch information
tetsuharuohzeki committed Dec 10, 2015
1 parent b756375 commit e8c12c1
Show file tree
Hide file tree
Showing 17 changed files with 23 additions and 30 deletions.
4 changes: 2 additions & 2 deletions components/canvas/canvas_paint_task.rs
Expand Up @@ -49,7 +49,7 @@ impl<'a> CanvasPaintTask<'a> {
//copy the data to the destination vector
for _ in 0..src_read_rect.size.height {
let row = &src_data[src .. src + (4 * src_read_rect.size.width) as usize];
image_data.push_all(row);
image_data.extend_from_slice(row);
src += stride as usize;
}

Expand Down Expand Up @@ -707,7 +707,7 @@ fn crop_image(image_data: Vec<u8>,
let mut src = (crop_rect.origin.y * stride + crop_rect.origin.x * 4) as usize;
for _ in 0..crop_rect.size.height {
let row = &image_data[src .. src + (4 * crop_rect.size.width) as usize];
new_image_data.push_all(row);
new_image_data.extend_from_slice(row);
src += stride as usize;
}
new_image_data
Expand Down
1 change: 0 additions & 1 deletion components/canvas/lib.rs
Expand Up @@ -5,7 +5,6 @@
#![feature(core)]
#![feature(nonzero)]
#![feature(slice_bytes)]
#![feature(vec_push_all)]
#![feature(plugin)]
#![plugin(plugins)]

Expand Down
6 changes: 3 additions & 3 deletions components/compositing/constellation.rs
Expand Up @@ -1433,9 +1433,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let mut pipelines_to_close = vec!();

let frame = self.frame(frame_id);
pipelines_to_close.push_all(&frame.next);
pipelines_to_close.extend_from_slice(&frame.next);
pipelines_to_close.push(frame.current);
pipelines_to_close.push_all(&frame.prev);
pipelines_to_close.extend_from_slice(&frame.prev);

pipelines_to_close
};
Expand All @@ -1462,7 +1462,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let mut frames_to_close = vec!();

let pipeline = self.pipeline(pipeline_id);
frames_to_close.push_all(&pipeline.children);
frames_to_close.extend_from_slice(&pipeline.children);

frames_to_close
};
Expand Down
1 change: 0 additions & 1 deletion components/compositing/lib.rs
Expand Up @@ -7,7 +7,6 @@
#![feature(iter_cmp)]
#![feature(plugin)]
#![feature(slice_bytes)]
#![feature(vec_push_all)]
#![feature(mpsc_select)]
#![feature(plugin)]
#![plugin(plugins)]
Expand Down
1 change: 0 additions & 1 deletion components/gfx/lib.rs
Expand Up @@ -15,7 +15,6 @@
#![feature(plugin)]
#![feature(str_char)]
#![feature(unique)]
#![feature(vec_push_all)]

#![plugin(plugins)]
#![plugin(serde_macros)]
Expand Down
2 changes: 1 addition & 1 deletion components/gfx/text/glyph.rs
Expand Up @@ -226,7 +226,7 @@ impl<'a> DetailedGlyphStore {
*/

self.detail_lookup.push(entry);
self.detail_buffer.push_all(glyphs);
self.detail_buffer.extend_from_slice(glyphs);
self.lookup_is_sorted = false;
}

Expand Down
2 changes: 1 addition & 1 deletion components/net/image_cache_task.rs
Expand Up @@ -343,7 +343,7 @@ impl ImageCache {
(ResponseAction::HeadersAvailable(_), _) => {}
(ResponseAction::DataAvailable(data), _) => {
let pending_load = self.pending_loads.get_by_key_mut(&msg.key).unwrap();
pending_load.bytes.push_all(&data);
pending_load.bytes.extend_from_slice(&data);
}
(ResponseAction::ResponseComplete(result), key) => {
match result {
Expand Down
1 change: 0 additions & 1 deletion components/net/lib.rs
Expand Up @@ -6,7 +6,6 @@
#![feature(fnbox)]
#![feature(mpsc_select)]
#![feature(plugin)]
#![feature(vec_push_all)]
#![feature(plugin)]
#![plugin(plugins)]

Expand Down
3 changes: 1 addition & 2 deletions components/net_traits/lib.rs
Expand Up @@ -8,7 +8,6 @@
#![feature(plugin)]
#![feature(slice_patterns)]
#![feature(step_by)]
#![feature(vec_push_all)]
#![feature(custom_attribute)]
#![plugin(serde_macros, plugins)]

Expand Down Expand Up @@ -423,7 +422,7 @@ pub fn load_whole_resource(resource_task: &ResourceTask, url: Url, pipeline_id:
let mut buf = vec!();
loop {
match response.progress_port.recv().unwrap() {
ProgressMsg::Payload(data) => buf.push_all(&data),
ProgressMsg::Payload(data) => buf.extend_from_slice(&data),
ProgressMsg::Done(Ok(())) => return Ok((response.metadata, buf)),
ProgressMsg::Done(Err(e)) => return Err(e)
}
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/blob.rs
Expand Up @@ -140,7 +140,7 @@ impl BlobMethods for Blob {
let start = relativeStart.to_usize().unwrap();
let end = (relativeStart + span).to_usize().unwrap();
let mut bytes: Vec<u8> = Vec::new();
bytes.push_all(&vec[start..end]);
bytes.extend_from_slice(&vec[start..end]);
Blob::new(global.r(), Some(bytes), &relativeContentType)
}
}
Expand Down
10 changes: 5 additions & 5 deletions components/script/dom/xmlhttprequest.rs
Expand Up @@ -253,7 +253,7 @@ impl XMLHttpRequest {
}

fn data_available(&mut self, payload: Vec<u8>) {
self.buf.borrow_mut().push_all(&payload);
self.buf.borrow_mut().extend_from_slice(&payload);
self.xhr.root().process_data_available(self.gen_id, self.buf.borrow().clone());
}

Expand Down Expand Up @@ -403,8 +403,8 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
Some(raw) => {
debug!("SetRequestHeader: old value = {:?}", raw[0]);
let mut buf = raw[0].clone();
buf.push_all(b", ");
buf.push_all(&value);
buf.extend_from_slice(b", ");
buf.extend_from_slice(&value);
debug!("SetRequestHeader: new value = {:?}", buf);
value = ByteString::new(buf);
},
Expand Down Expand Up @@ -530,8 +530,8 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
fn join_raw(a: &str, b: &str) -> Vec<u8> {
let len = a.len() + b.len();
let mut vec = Vec::with_capacity(len);
vec.push_all(a.as_bytes());
vec.push_all(b.as_bytes());
vec.extend_from_slice(a.as_bytes());
vec.extend_from_slice(b.as_bytes());
vec
}

Expand Down
1 change: 0 additions & 1 deletion components/script/lib.rs
Expand Up @@ -22,7 +22,6 @@
#![feature(slice_patterns)]
#![feature(str_utf16)]
#![feature(unicode)]
#![feature(vec_push_all)]

#![deny(unsafe_code)]
#![allow(non_snake_case)]
Expand Down
6 changes: 3 additions & 3 deletions components/script/textinput.rs
Expand Up @@ -235,9 +235,9 @@ impl<T: ClipboardProvider> TextInput<T> {
insert_lines[last_insert_lines_index].push_str(suffix);

let mut new_lines = vec!();
new_lines.push_all(lines_prefix);
new_lines.push_all(&insert_lines);
new_lines.push_all(lines_suffix);
new_lines.extend_from_slice(lines_prefix);
new_lines.extend_from_slice(&insert_lines);
new_lines.extend_from_slice(lines_suffix);
new_lines
};

Expand Down
2 changes: 1 addition & 1 deletion components/style/animation.rs
Expand Up @@ -814,7 +814,7 @@ fn interpolate_transform_list(from_list: &[TransformOperation],
}
} else {
// TODO(gw): Implement matrix decomposition and interpolation
result.push_all(from_list);
result.extend_from_slice(from_list);
}

TransformList(Some(result))
Expand Down
1 change: 0 additions & 1 deletion components/style/lib.rs
Expand Up @@ -9,7 +9,6 @@
#![feature(custom_attribute)]
#![feature(custom_derive)]
#![feature(plugin)]
#![feature(vec_push_all)]

#![plugin(serde_macros)]
#![plugin(serde_macros)]
Expand Down
2 changes: 1 addition & 1 deletion components/style/stylesheets.rs
Expand Up @@ -87,7 +87,7 @@ impl Stylesheet {
let mut bytes = vec![];
// TODO: incremental decoding and tokenization/parsing
for chunk in input {
bytes.push_all(&chunk)
bytes.extend_from_slice(&chunk)
}
Stylesheet::from_bytes(&bytes, base_url, protocol_encoding_label,
environment_encoding, origin, error_reporter)
Expand Down
8 changes: 4 additions & 4 deletions components/style/values.rs
Expand Up @@ -628,7 +628,7 @@ pub mod specified {
let mut simplified = Vec::new();
for product in &node.products {
match try!(CalcLengthOrPercentage::simplify_product(product)) {
SimplifiedValueNode::Sum(box sum) => simplified.push_all(&sum.values),
SimplifiedValueNode::Sum(box sum) => simplified.extend_from_slice(&sum.values),
val => simplified.push(val),
}
}
Expand Down Expand Up @@ -681,7 +681,7 @@ pub mod specified {
let mut simplified = Vec::new();
for ref node in ast.products {
match try!(CalcLengthOrPercentage::simplify_product(node)) {
SimplifiedValueNode::Sum(sum) => simplified.push_all(&sum.values),
SimplifiedValueNode::Sum(sum) => simplified.extend_from_slice(&sum.values),
value => simplified.push(value),
}
}
Expand Down Expand Up @@ -751,7 +751,7 @@ pub mod specified {
let mut simplified = Vec::new();
for ref node in ast.products {
match try!(CalcLengthOrPercentage::simplify_product(node)) {
SimplifiedValueNode::Sum(sum) => simplified.push_all(&sum.values),
SimplifiedValueNode::Sum(sum) => simplified.extend_from_slice(&sum.values),
value => simplified.push(value),
}
}
Expand All @@ -778,7 +778,7 @@ pub mod specified {
let mut simplified = Vec::new();
for ref node in ast.products {
match try!(CalcLengthOrPercentage::simplify_product(node)) {
SimplifiedValueNode::Sum(sum) => simplified.push_all(&sum.values),
SimplifiedValueNode::Sum(sum) => simplified.extend_from_slice(&sum.values),
value => simplified.push(value),
}
}
Expand Down

0 comments on commit e8c12c1

Please sign in to comment.