Mark debug functions cold.

This commit is contained in:
Stephen Chung
2022-09-27 08:52:39 +08:00
parent 20d4b71591
commit 25476d1cea
16 changed files with 42 additions and 7 deletions

View File

@@ -42,6 +42,8 @@ impl Default for AST {
}
impl fmt::Debug for AST {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut fp = f.debug_struct("AST");

View File

@@ -117,6 +117,8 @@ pub struct FnCallHashes {
}
impl fmt::Debug for FnCallHashes {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[cfg(not(feature = "no_function"))]
if self.script != 0 {
@@ -199,6 +201,8 @@ pub struct FnCallExpr {
}
impl fmt::Debug for FnCallExpr {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut ff = f.debug_struct("FnCallExpr");
#[cfg(not(feature = "no_module"))]
@@ -294,7 +298,8 @@ impl<F: Float> DerefMut for FloatWrapper<F> {
#[cfg(not(feature = "no_float"))]
impl<F: Float + fmt::Debug> fmt::Debug for FloatWrapper<F> {
#[inline(always)]
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&self.0, f)
}
@@ -448,6 +453,8 @@ impl Default for Expr {
}
impl fmt::Debug for Expr {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut display_pos = format!(" @ {:?}", self.start_position());

View File

@@ -20,6 +20,8 @@ pub struct Ident {
}
impl fmt::Debug for Ident {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.name)?;
self.pos.debug_print(f)

View File

@@ -29,6 +29,8 @@ pub struct Namespace {
}
impl fmt::Debug for Namespace {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_empty() {
return f.write_str("NONE");

View File

@@ -106,6 +106,8 @@ impl OpAssignment {
}
impl fmt::Debug for OpAssignment {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_op_assignment() {
f.debug_struct("OpAssignment")
@@ -178,7 +180,8 @@ pub enum RangeCase {
}
impl fmt::Debug for RangeCase {
#[inline]
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::ExclusiveInt(r, n) => write!(f, "{}..{} => {}", r.start, r.end, n),
@@ -454,6 +457,8 @@ impl AsMut<[Stmt]> for StmtBlock {
}
impl fmt::Debug for StmtBlock {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("Block")?;
fmt::Debug::fmt(&self.block, f)?;