Put the swizzle operators behind a feature flag "swizzle" to avoid increasing
the binary size by approximately 20% by default.
This commit is contained in:
parent
768b6b71f0
commit
12547b5bcb
2 changed files with 16 additions and 7 deletions
|
@ -18,6 +18,7 @@ name = "cgmath"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
unstable = []
|
unstable = []
|
||||||
|
swizzle = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
approx = "0.1"
|
approx = "0.1"
|
||||||
|
|
8
build.rs
8
build.rs
|
@ -6,6 +6,7 @@ use std::string::String;
|
||||||
|
|
||||||
/// Generate the name of the swizzle function and what it returns.
|
/// Generate the name of the swizzle function and what it returns.
|
||||||
/// NOTE: This function assumes that variables are in ASCII format
|
/// NOTE: This function assumes that variables are in ASCII format
|
||||||
|
#[cfg(feature = "swizzle")]
|
||||||
fn gen_swizzle_nth<'a>(variables: &'a str, mut i: usize, upto: usize) -> Option<(String, String)> {
|
fn gen_swizzle_nth<'a>(variables: &'a str, mut i: usize, upto: usize) -> Option<(String, String)> {
|
||||||
debug_assert!(i > 0); // zeroth permutation is empty
|
debug_assert!(i > 0); // zeroth permutation is empty
|
||||||
let mut swizzle_impl = String::new();
|
let mut swizzle_impl = String::new();
|
||||||
|
@ -27,6 +28,7 @@ fn gen_swizzle_nth<'a>(variables: &'a str, mut i: usize, upto: usize) -> Option<
|
||||||
/// `upto`: largest output vector size (e.g. for `variables = "xy"` and `upto = 4`, `xyxy()` is a
|
/// `upto`: largest output vector size (e.g. for `variables = "xy"` and `upto = 4`, `xyxy()` is a
|
||||||
/// valid swizzle operator.
|
/// valid swizzle operator.
|
||||||
/// NOTE: This function assumes that variables are in ASCII format
|
/// NOTE: This function assumes that variables are in ASCII format
|
||||||
|
#[cfg(feature = "swizzle")]
|
||||||
fn gen_swizzle_functions(variables: &'static str, upto: usize) -> String {
|
fn gen_swizzle_functions(variables: &'static str, upto: usize) -> String {
|
||||||
let mut result = String::new();
|
let mut result = String::new();
|
||||||
let nn = (variables.len()+1).pow(upto as u32);
|
let nn = (variables.len()+1).pow(upto as u32);
|
||||||
|
@ -43,6 +45,12 @@ fn gen_swizzle_functions(variables: &'static str, upto: usize) -> String {
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "swizzle"))]
|
||||||
|
fn gen_swizzle_functions(_: &'static str, _: usize) -> String {
|
||||||
|
String::new()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// This script generates the macro for building swizzle operators for multidimensional
|
/// This script generates the macro for building swizzle operators for multidimensional
|
||||||
/// vectors and points. This macro is included in macros.rs
|
/// vectors and points. This macro is included in macros.rs
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
Loading…
Reference in a new issue