Use debug_assert instead of assert in code where performance is important.
This commit is contained in:
@@ -119,7 +119,7 @@ struct EbbHeaderBlockData<Variable> {
|
|||||||
pub struct Block(u32);
|
pub struct Block(u32);
|
||||||
impl EntityRef for Block {
|
impl EntityRef for Block {
|
||||||
fn new(index: usize) -> Self {
|
fn new(index: usize) -> Self {
|
||||||
assert!(index < (u32::MAX as usize));
|
debug_assert!(index < (u32::MAX as usize));
|
||||||
Block(index as u32)
|
Block(index as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,7 +362,7 @@ where
|
|||||||
let (undef_vars, ebb): (Vec<(Variable, Value)>, Ebb) = match self.blocks[block] {
|
let (undef_vars, ebb): (Vec<(Variable, Value)>, Ebb) = match self.blocks[block] {
|
||||||
BlockData::EbbBody { .. } => panic!("this should not happen"),
|
BlockData::EbbBody { .. } => panic!("this should not happen"),
|
||||||
BlockData::EbbHeader(ref mut data) => {
|
BlockData::EbbHeader(ref mut data) => {
|
||||||
assert!(!data.sealed);
|
debug_assert!(!data.sealed);
|
||||||
// Extract the undef_variables data from the block so that we
|
// Extract the undef_variables data from the block so that we
|
||||||
// can iterate over it without borrowing the whole builder.
|
// can iterate over it without borrowing the whole builder.
|
||||||
let mut undef_variables = Vec::new();
|
let mut undef_variables = Vec::new();
|
||||||
@@ -390,8 +390,8 @@ where
|
|||||||
match self.blocks[block] {
|
match self.blocks[block] {
|
||||||
BlockData::EbbBody { .. } => panic!("this should not happen"),
|
BlockData::EbbBody { .. } => panic!("this should not happen"),
|
||||||
BlockData::EbbHeader(ref mut data) => {
|
BlockData::EbbHeader(ref mut data) => {
|
||||||
assert!(!data.sealed);
|
debug_assert!(!data.sealed);
|
||||||
assert!(data.undef_variables.is_empty());
|
debug_assert!(data.undef_variables.is_empty());
|
||||||
data.sealed = true;
|
data.sealed = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ pub struct Memory {
|
|||||||
pub struct Local(pub u32);
|
pub struct Local(pub u32);
|
||||||
impl cretonne::entity::EntityRef for Local {
|
impl cretonne::entity::EntityRef for Local {
|
||||||
fn new(index: usize) -> Self {
|
fn new(index: usize) -> Self {
|
||||||
assert!(index < (u32::MAX as usize));
|
debug_assert!(index < (u32::MAX as usize));
|
||||||
Local(index as u32)
|
Local(index as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user