Better path usage and "extern crate" removal in sub-crates.

This commit is contained in:
Nathan Vegdahl 2018-12-16 13:14:06 -08:00
parent 28a07de456
commit 508cda6021
14 changed files with 38 additions and 56 deletions

View File

@ -1,9 +1,6 @@
// Generate table for traversal order of quad BVHs.
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;
use std::{env, fs::File, io::Write, path::Path};
fn main() {
// Build the traversal table.

View File

@ -1,7 +1,4 @@
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;
use std::{env, fs::File, io::Write, path::Path};
#[derive(Copy, Clone)]
struct Chromaticities {

View File

@ -3,9 +3,11 @@
/// Implementation of Float4 for x86_64 platforms with SSE support.
#[cfg(all(target_arch = "x86_64", target_feature = "sse"))]
mod x86_64_sse {
use std::arch::x86_64::__m128;
use std::cmp::PartialEq;
use std::ops::{Add, AddAssign, BitAnd, BitOr, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
use std::{
arch::x86_64::__m128,
cmp::PartialEq,
ops::{Add, AddAssign, BitAnd, BitOr, Div, DivAssign, Mul, MulAssign, Sub, SubAssign},
};
#[derive(Debug, Copy, Clone)]
pub struct Float4 {
@ -626,8 +628,10 @@ mod x86_64_sse {
/// Implementation fo Float4 for any platform, foregoing any
/// platform-specific optimizations.
mod fallback {
use std::cmp::PartialEq;
use std::ops::{Add, AddAssign, BitAnd, BitOr, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
use std::{
cmp::PartialEq,
ops::{Add, AddAssign, BitAnd, BitOr, Div, DivAssign, Mul, MulAssign, Sub, SubAssign},
};
#[derive(Debug, Copy, Clone)]
pub struct Float4 {

View File

@ -22,10 +22,7 @@
// Generate Rust code for evaluating Halton points with Faure-permutations for different bases.
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;
use std::{env, fs::File, io::Write, path::Path};
/// How many components to generate.
const NUM_DIMENSIONS: usize = 128;

View File

@ -1,16 +1,11 @@
#![allow(dead_code)]
extern crate float4;
mod matrix;
mod normal;
mod point;
mod vector;
pub use self::matrix::Matrix4x4;
pub use self::normal::Normal;
pub use self::point::Point;
pub use self::vector::Vector;
pub use self::{matrix::Matrix4x4, normal::Normal, point::Point, vector::Vector};
/// Trait for calculating dot products.
pub trait DotProduct {

View File

@ -1,6 +1,5 @@
#![allow(dead_code)]
use std;
use std::ops::{Index, IndexMut, Mul};
use float4::{invert, transpose, Float4};

View File

@ -1,12 +1,13 @@
#![allow(dead_code)]
use std::cmp::PartialEq;
use std::ops::{Add, Div, Mul, Neg, Sub};
use std::{
cmp::PartialEq,
ops::{Add, Div, Mul, Neg, Sub},
};
use float4::Float4;
use super::{CrossProduct, DotProduct};
use super::{Matrix4x4, Vector};
use super::{CrossProduct, DotProduct, Matrix4x4, Vector};
/// A surface normal in 3d homogeneous space.
#[derive(Debug, Copy, Clone)]

View File

@ -1,12 +1,13 @@
#![allow(dead_code)]
use std::cmp::PartialEq;
use std::ops::{Add, Mul, Sub};
use std::{
cmp::PartialEq,
ops::{Add, Mul, Sub},
};
use float4::Float4;
use super::Matrix4x4;
use super::Vector;
use super::{Matrix4x4, Vector};
/// A position in 3d homogeneous space.
#[derive(Debug, Copy, Clone)]

View File

@ -1,12 +1,13 @@
#![allow(dead_code)]
use std::cmp::PartialEq;
use std::ops::{Add, Div, Mul, Neg, Sub};
use std::{
cmp::PartialEq,
ops::{Add, Div, Mul, Neg, Sub},
};
use float4::Float4;
use super::{CrossProduct, DotProduct};
use super::{Matrix4x4, Normal, Point};
use super::{CrossProduct, DotProduct, Matrix4x4, Normal, Point};
/// A direction vector in 3d homogeneous space.
#[derive(Debug, Copy, Clone)]

View File

@ -2,10 +2,12 @@
#![allow(clippy::needless_return)]
#![allow(clippy::mut_from_ref)]
use std::cell::{Cell, RefCell};
use std::cmp::max;
use std::mem::{align_of, size_of};
use std::slice;
use std::{
cell::{Cell, RefCell},
cmp::max,
mem::{align_of, size_of},
slice,
};
const GROWTH_FRACTION: usize = 8; // 1/N (smaller number leads to bigger allocations)
const DEFAULT_MIN_BLOCK_SIZE: usize = 1 << 10; // 1 KiB

View File

@ -1,9 +1,4 @@
#[macro_use]
extern crate bencher;
extern crate oct32norm;
extern crate rand;
use bencher::{black_box, Bencher};
use bencher::{benchmark_group, benchmark_main, black_box, Bencher};
use oct32norm::{decode, encode};
use rand::{rngs::SmallRng, FromEntropy, Rng};

View File

@ -22,8 +22,7 @@
mod matrices;
pub use crate::matrices::NUM_DIMENSIONS;
use crate::matrices::{MATRICES, SIZE};
pub use crate::matrices::{MATRICES, NUM_DIMENSIONS, SIZE};
/// Compute one component of the Sobol'-sequence, where the component
/// corresponds to the dimension parameter, and the index specifies

View File

@ -4,10 +4,9 @@
#![allow(clippy::useless_let_if_seq)]
#![allow(clippy::cyclomatic_complexity)]
extern crate float4;
use std::f32;
use float4::Float4;
use std::f32;
mod spectra_tables;

View File

@ -1,9 +1,4 @@
#[macro_use]
extern crate bencher;
extern crate rand;
extern crate trifloat;
use bencher::{black_box, Bencher};
use bencher::{benchmark_group, benchmark_main, black_box, Bencher};
use rand::{rngs::SmallRng, FromEntropy, Rng};
use trifloat::{decode, encode};