From 7d8c1332f87b54a79aad73a14816df3d7f0482f3 Mon Sep 17 00:00:00 2001 From: Bogdan <165001420+OptionalAssistant@users.noreply.github.com> Date: Wed, 15 May 2024 09:50:13 +0300 Subject: [PATCH] Remove duplicating code Using function instead of rewriting the same code --- zasm/src/zasm/src/core/error.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/zasm/src/zasm/src/core/error.cpp b/zasm/src/zasm/src/core/error.cpp index 8dc13b6..3a529ae 100644 --- a/zasm/src/zasm/src/core/error.cpp +++ b/zasm/src/zasm/src/core/error.cpp @@ -11,12 +11,16 @@ namespace zasm ErrorCode code; std::string message; }; + static bool isExtError(std::uint64_t data) noexcept + { + return (data & kErrorExtBit) != 0; + } // TODO: This is not fully portable so we should check for systems where // we have to use a different approach. static ErrorExt* toErrorExt(std::uint64_t data) noexcept { - assert((data & kErrorExtBit) != 0); + assert(isExtError(data)); auto* ext = reinterpret_cast(data & ~kErrorExtBit); return ext; @@ -27,11 +31,6 @@ namespace zasm return static_cast(reinterpret_cast(ext)) | kErrorExtBit; } - static bool isExtError(std::uint64_t data) noexcept - { - return (data & kErrorExtBit) != 0; - } - Error::Error(const Error& other) { if (isExtError(other._data))