Skip to main content

safe_sub

Function safe_sub 

Source
pub fn safe_sub(a: i64, b: i64) -> Result<i64, ConsensusError>
Expand description

Fast-path subtraction with overflow checking

Uses manual overflow detection for common cases which is faster than checked_sub for the hot path. Falls back to checked_sub for edge cases.

ยงSafety

This function maintains the same safety guarantees as checked_sub, but with better performance for common cases.