Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address some issues found by rust-clippy. #202

Merged
merged 4 commits into from Feb 26, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -280,7 +280,7 @@ impl AABBTree {
let children = {
let node = self.node_mut(node_index);
if node.split_rect.intersects(rect) {
if node.draw_list_group_segments.len() > 0 &&
if !node.draw_list_group_segments.is_empty() &&
node.actual_rect.intersects(rect) {
debug_assert!(node.children.is_none());
node.is_visible = true;
@@ -304,7 +304,7 @@ impl AABBTree {
for node in &mut self.nodes {
node.is_visible = false;
}
if self.nodes.len() > 0 {
if !self.nodes.is_empty() {
self.check_node_visibility(NodeIndex(0), &rect);
}
}
@@ -289,7 +289,7 @@ impl<'a> BatchBuilder<'a> {
old_rect
}

pub fn push_complex_clip(&mut self, clip: &Vec<ComplexClipRegion>) {
pub fn push_complex_clip(&mut self, clip: &[ComplexClipRegion]) {
// TODO(gw): Handle nested complex clips!
debug_assert!(clip.len() == 0 || clip.len() == 1);
if clip.len() == 1 {
@@ -162,9 +162,9 @@ impl DebugRenderer {
pub fn render(&mut self,
device: &mut Device,
viewport_size: &Size2D<u32>) {
if self.font_indices.len() > 0 ||
self.line_vertices.len() > 0 ||
self.tri_vertices.len() > 0 {
if !self.font_indices.is_empty() ||
!self.line_vertices.is_empty() ||
!self.tri_vertices.is_empty() {
gl::disable(gl::DEPTH_TEST);
gl::enable(gl::BLEND);
gl::blend_equation(gl::FUNC_ADD);
@@ -181,7 +181,7 @@ impl RenderTarget {
resource_cache: &mut ResourceCache,
draw_list_groups: &HashMap<DrawListGroupId, DrawListGroup, BuildHasherDefault<FnvHasher>>,
layers: &HashMap<ScrollLayerId, Layer, BuildHasherDefault<FnvHasher>>,
stacking_context_info: &Vec<StackingContextInfo>,
stacking_context_info: &[StackingContextInfo],
device_pixel_ratio: f32) -> DrawLayer {
let mut commands = vec![];
for item in &self.items {
@@ -514,7 +514,7 @@ impl StackingContextHelpers for StackingContext {
if self.needs_composition_operation_for_mix_blend_mode() {
composition_operations.push(CompositionOp::MixBlend(self.mix_blend_mode));
}
for filter in self.filters.iter() {
for filter in &self.filters {
match *filter {
FilterOp::Blur(radius) => {
composition_operations.push(CompositionOp::Filter(LowLevelFilterOp::Blur(
@@ -776,7 +776,7 @@ impl Frame {
}

fn add_items_to_target(&mut self,
scene_items: &Vec<SceneItem>,
scene_items: &[SceneItem],
info: &FlattenInfo,
target: &mut RenderTarget,
context: &mut FlattenContext,
@@ -212,7 +212,7 @@ impl PackedVertexForQuad {
muv: &RectUv<DevicePixel>,
color_mode: PackedVertexColorMode)
-> PackedVertexForQuad {
return PackedVertexForQuad {
PackedVertexForQuad {
x: position.origin.x,
y: position.origin.y,
width: position.size.width,
@@ -244,7 +244,7 @@ impl PackedVertexForQuad {
PackedVertexColorMode::Gradient => 0x00,
PackedVertexColorMode::BorderCorner => 0x80,
},
};
}
}
}

@@ -19,7 +19,7 @@ pub trait NodeCompiler {
resource_cache: &ResourceCache,
frame_id: FrameId,
device_pixel_ratio: f32,
stacking_context_info: &Vec<StackingContextInfo>,
stacking_context_info: &[StackingContextInfo],
draw_list_groups: &HashMap<DrawListGroupId, DrawListGroup, BuildHasherDefault<FnvHasher>>);
}

@@ -28,7 +28,7 @@ impl NodeCompiler for AABBTreeNode {
resource_cache: &ResourceCache,
frame_id: FrameId,
device_pixel_ratio: f32,
stacking_context_info: &Vec<StackingContextInfo>,
stacking_context_info: &[StackingContextInfo],
draw_list_groups: &HashMap<DrawListGroupId, DrawListGroup, BuildHasherDefault<FnvHasher>>) {
let mut compiled_node = CompiledNode::new();
let mut vertex_buffer = VertexBuffer::new();
@@ -134,7 +134,7 @@ impl NodeCompiler for AABBTreeNode {
}

let batches = builder.finalize();
if batches.len() > 0 {
if !batches.is_empty() {
compiled_node.batch_list.push(BatchList {
batches: batches,
draw_list_group_id: draw_list_group_segment.draw_list_group_id,
@@ -239,7 +239,7 @@ impl ProfileGraph {
stats.max_value = stats.max_value.max(*value);
}

if self.values.len() > 0 {
if !self.values.is_empty() {
stats.mean_value = stats.mean_value / self.values.len() as f32;
}

@@ -57,7 +57,7 @@ impl RenderBackend {
device_pixel_ratio,
enable_aa);

let backend = RenderBackend {
RenderBackend {
thread_pool: thread_pool,
api_rx: api_rx,
result_tx: result_tx,
@@ -70,9 +70,7 @@ impl RenderBackend {
webrender_context_handle: webrender_context_handle,
webgl_contexts: HashMap::new(),
current_bound_webgl_context_id: None,
};

backend
}
}

pub fn run(&mut self) {
@@ -295,7 +293,7 @@ impl RenderBackend {
self.device_pixel_ratio);

let pending_update = self.resource_cache.pending_updates();
if pending_update.updates.len() > 0 {
if !pending_update.updates.is_empty() {
self.result_tx.send(ResultMsg::UpdateTextureCache(pending_update)).unwrap();
}

@@ -894,7 +894,7 @@ impl Renderer {
f: F)
where F: Fn(&Rect<f32>) -> [PackedVertexForTextureCacheUpdate; 4] {
// FIXME(pcwalton): Use a hash table if this linear search shows up in the profile.
for batch in self.raster_batches.iter_mut() {
for batch in &mut self.raster_batches {
if batch.add_rect_if_possible(dest_texture_id,
color_texture_id,
program_id,
@@ -932,7 +932,7 @@ impl Renderer {

fn flush_raster_batches(&mut self) {
let batches = mem::replace(&mut self.raster_batches, vec![]);
if batches.len() > 0 {
if !batches.is_empty() {
//println!("flushing {:?} raster batches", batches.len());

gl::disable(gl::DEPTH_TEST);
@@ -1201,7 +1201,7 @@ impl Renderer {
self.device.bind_program(self.quad_program_id,
&projection);

if info.offset_palette.len() > 0 {
if !info.offset_palette.is_empty() {
// TODO(gw): Avoid alloc here...
let mut floats = Vec::new();
for vec in &info.offset_palette {
@@ -1313,7 +1313,7 @@ impl Renderer {
draw_call.first_instance);
self.device.bind_vao(vao_id);

if draw_call.tile_params.len() > 0 {
if !draw_call.tile_params.is_empty() {
// TODO(gw): Avoid alloc here...
let mut floats = Vec::new();
for vec in &draw_call.tile_params {
@@ -1327,7 +1327,7 @@ impl Renderer {
&floats);
}

if draw_call.clip_rects.len() > 0 {
if !draw_call.clip_rects.is_empty() {
// TODO(gw): Avoid alloc here...
let mut floats = Vec::new();
for rect in &draw_call.clip_rects {
@@ -94,7 +94,7 @@ impl<K,V> ResourceClassCache<K,V> where K: Clone + Hash + Eq + Debug, V: Resourc

fn expire_old_resources(&mut self, texture_cache: &mut TextureCache, frame_id: FrameId) {
let mut resources_to_destroy = vec![];
for (key, this_frame_id) in self.last_access_times.iter() {
for (key, this_frame_id) in &self.last_access_times {
if *this_frame_id < frame_id {
resources_to_destroy.push((*key).clone())
}
@@ -160,7 +160,7 @@ impl BuildRequiredResources for AABBTreeNode {
let display_item = &draw_list.items[index as usize];

// Handle border radius for complex clipping regions.
for complex_clip_region in display_item.clip.complex.iter() {
for complex_clip_region in &display_item.clip.complex {
resource_list.add_radius_raster_for_border_radii(&complex_clip_region.radii);
}

@@ -822,7 +822,7 @@ impl TextureCache {
}
}

for update in self.pending_updates.updates.iter_mut() {
for update in &mut self.pending_updates.updates {
if update.id == old_texture_id {
update.id = new_texture_id
}
@@ -49,7 +49,7 @@ impl MatrixHelpers for Matrix4 {
let bottom_right = self.transform_point(&rect.bottom_right());
let (mut min_x, mut min_y) = (top_left.x.clone(), top_left.y.clone());
let (mut max_x, mut max_y) = (min_x.clone(), min_y.clone());
for point in [ top_right, bottom_left, bottom_right ].iter() {
for point in &[ top_right, bottom_left, bottom_right ] {
if point.x < min_x {
min_x = point.x.clone()
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.