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 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Prefer 'is_empty' over 'len' when doing existential check.

  • Loading branch information
frewsxcv committed Feb 26, 2016
commit 630288db9bd5b078860878aa02e87c01314090db
@@ -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);
}
}
@@ -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);
@@ -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;
}

@@ -295,7 +295,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();
}

@@ -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 {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.