Skip to main content

safe_add

Function safe_add 

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

Fast-path addition with overflow checking

Uses manual overflow detection for common cases (both positive values) which is faster than checked_add for the hot path. Falls back to checked_add for edge cases.

ยงSafety

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