From bfc09299d8b8e7697667e6204933b8607ad99c7f Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 12 Oct 2019 08:51:48 -0700 Subject: [PATCH] clippy --- src/frontend/software/mod.rs | 9 +++++---- src/frontend/software/termwindow.rs | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/frontend/software/mod.rs b/src/frontend/software/mod.rs index 14437c6e2..c6698afdd 100644 --- a/src/frontend/software/mod.rs +++ b/src/frontend/software/mod.rs @@ -8,7 +8,8 @@ use ::window::*; use failure::Fallible; use promise::{BasicExecutor, Executor, SpawnFunc}; use std::rc::Rc; -use std::sync::{Arc, Mutex}; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; mod termwindow; @@ -17,16 +18,16 @@ pub struct SoftwareFrontEnd { } lazy_static::lazy_static! { -static ref USE_OPENGL: Mutex = Mutex::new(true); +static ref USE_OPENGL: AtomicBool = AtomicBool::new(true); } pub fn is_opengl_enabled() -> bool { - *USE_OPENGL.lock().unwrap() + USE_OPENGL.load(Ordering::Acquire) } impl SoftwareFrontEnd { pub fn try_new_no_opengl(mux: &Rc) -> Fallible> { - *USE_OPENGL.lock().unwrap() = false; + USE_OPENGL.store(false, Ordering::Release); Self::try_new(mux) } diff --git a/src/frontend/software/termwindow.rs b/src/frontend/software/termwindow.rs index 4a46150f5..db311fcf9 100644 --- a/src/frontend/software/termwindow.rs +++ b/src/frontend/software/termwindow.rs @@ -395,13 +395,13 @@ impl RenderState { ) -> Fallible<()> { match self { RenderState::Software(software) => { - let size = size.unwrap_or(software.glyph_cache.borrow().atlas.size()); + let size = size.unwrap_or_else(|| software.glyph_cache.borrow().atlas.size()); let mut glyph_cache = GlyphCache::new(fonts, size); software.util_sprites = UtilSprites::new(&mut glyph_cache, metrics)?; *software.glyph_cache.borrow_mut() = glyph_cache; } RenderState::GL(gl) => { - let size = size.unwrap_or(gl.glyph_cache.borrow().atlas.size()); + let size = size.unwrap_or_else(|| gl.glyph_cache.borrow().atlas.size()); let mut glyph_cache = GlyphCache::new_gl(&gl.context, fonts, size)?; gl.util_sprites = UtilSprites::new(&mut glyph_cache, metrics)?; *gl.glyph_cache.borrow_mut() = glyph_cache; @@ -720,7 +720,7 @@ impl TermWindow { window.show(); if super::is_opengl_enabled() { - window.enable_opengl(|any, window, maybe_ctx| { + window.enable_opengl(|any, _window, maybe_ctx| { let termwindow = any.downcast_ref::().expect("to be TermWindow"); log::error!("I should use opengl"); @@ -732,7 +732,7 @@ impl TermWindow { &termwindow.render_metrics, ATLAS_SIZE, ) { - Ok(gl) => { + Ok(_) => { log::error!("OpenGL initialized!"); } Err(err) => {