Skip to content

Commit

Permalink
reexport hint from code
Browse files Browse the repository at this point in the history
- minor rustfmt update.
  • Loading branch information
joseluis committed Dec 21, 2023
1 parent b637e19 commit fd57d52
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/code/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// devela::meta
//
//! Code generation and meta-programming.
//! Code generation and meta-programming, extends
//! `std::`[`hint`].
//!
//! [`hint`]: core::hint
//

/* contains always compiled items */
Expand Down
20 changes: 20 additions & 0 deletions src/code/reexports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,23 @@ pub use devela_macros::{cif, coalesce, compile, compile_attr};

/// <span class="stab portability" title="re-exported from the `paste crate`">`paste`</span>
pub use super::paste::paste;

/* core::hint reexports */

use super::reexport;

reexport! { rust: core::hint, local_module: "code",
doc: "An identity function that hints to the compiler to be maximally
pessimistic about what black_box could do.",
black_box
}
reexport! { rust: core::hint, local_module: "code",
doc: "Emits a machine instruction to signal the processor that
it is running in a busy-wait spin-loop (“spin lock”).",
spin_loop
}
reexport! { rust: core::hint, local_module: "code",
doc: "Informs the compiler that the site which is calling this function
is not reachable, possibly enabling further optimizations.",
unreachable_unchecked
}
11 changes: 4 additions & 7 deletions src/text/ext/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ impl StrExt for str {
fn new_counter(buffer: &mut [u8], length: usize, separator: AsciiChar) -> &str {
assert![buffer.len() >= length];
if length == 0 {
// the cold path that returns an empty string slice
#[cold] #[inline] #[rustfmt::skip]
fn cold_empty_string() -> &'static str { "" }

cold_empty_string()
} else {
let separator = separator.as_u8();
Expand Down Expand Up @@ -156,10 +160,3 @@ impl StrExt for str {
}
}
}

// the cold path that returns an empty string slice
#[cold]
#[inline]
fn cold_empty_string() -> &'static str {
""
}

0 comments on commit fd57d52

Please sign in to comment.