From 72e4803939a036be86ac70b0bded554f1c4cc1bc Mon Sep 17 00:00:00 2001 From: hashlag Date: Sat, 29 Aug 2026 22:30:00 +0300 Subject: [PATCH] Branchless: Introduce TrueMask and FalseMask constants. --- Chaos/Padding/PadderIso7816.hpp | 4 ++-- Chaos/Service/Branchless.hpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Chaos/Padding/PadderIso7816.hpp b/Chaos/Padding/PadderIso7816.hpp index 547f6e7..cb1d5dd 100644 --- a/Chaos/Padding/PadderIso7816.hpp +++ b/Chaos/Padding/PadderIso7816.hpp @@ -52,8 +52,8 @@ public: uint8_t padSizeIncrement = 1; uint8_t padSize = 0; - uint8_t encountered0x80 = 0x00; - uint8_t onlyZerosPast0x80 = 0xFF; + uint8_t encountered0x80 = Branchless::FalseMask; + uint8_t onlyZerosPast0x80 = Branchless::TrueMask; InputIt it = end; while (it != begin && padSize < std::numeric_limits::max()) diff --git a/Chaos/Service/Branchless.hpp b/Chaos/Service/Branchless.hpp index 3c3dff4..9c16fd1 100644 --- a/Chaos/Service/Branchless.hpp +++ b/Chaos/Service/Branchless.hpp @@ -10,6 +10,9 @@ namespace Chaos::Service struct Branchless { + static constexpr uint8_t FalseMask = 0x00; + static constexpr uint8_t TrueMask = 0xFF; + template static constexpr OutUInt MsbMask(InUInt in) noexcept {