From 7bca7922eba1bb51a9625b223219eedb839f3cfd Mon Sep 17 00:00:00 2001 From: ikpil Date: Sat, 10 Jun 2023 13:27:27 +0900 Subject: [PATCH] refactoring DtStatus 1st --- src/DotRecast.Detour/DtStatus.cs | 26 +++++++++++++++++++++++ src/DotRecast.Detour/DtStatusExtension.cs | 25 ---------------------- 2 files changed, 26 insertions(+), 25 deletions(-) delete mode 100644 src/DotRecast.Detour/DtStatusExtension.cs diff --git a/src/DotRecast.Detour/DtStatus.cs b/src/DotRecast.Detour/DtStatus.cs index be9e059..63a2797 100644 --- a/src/DotRecast.Detour/DtStatus.cs +++ b/src/DotRecast.Detour/DtStatus.cs @@ -18,6 +18,8 @@ freely, subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ +using System.Runtime.CompilerServices; + namespace DotRecast.Detour { public class DtStatus @@ -45,5 +47,29 @@ namespace DotRecast.Detour { Value = value; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool IsSuccess() + { + return 0 != (Value & (DT_SUCCSESS.Value | DT_PARTIAL_RESULT.Value)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool IsFailed() + { + return 0 != (Value & (DT_FAILURE.Value | DT_INVALID_PARAM.Value)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool IsInProgress() + { + return 0 != (Value & DT_IN_PROGRESS.Value); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool IsPartial() + { + return 0 != (Value & DT_PARTIAL_RESULT.Value); + } } } \ No newline at end of file diff --git a/src/DotRecast.Detour/DtStatusExtension.cs b/src/DotRecast.Detour/DtStatusExtension.cs deleted file mode 100644 index 8d0da09..0000000 --- a/src/DotRecast.Detour/DtStatusExtension.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace DotRecast.Detour -{ - public static class DtStatusExtension - { - public static bool IsSuccess(this DtStatus @this) - { - return @this == DtStatus.DT_SUCCSESS || @this == DtStatus.DT_PARTIAL_RESULT; - } - - public static bool IsFailed(this DtStatus @this) - { - return @this == DtStatus.DT_FAILURE || @this == DtStatus.DT_INVALID_PARAM; - } - - public static bool IsInProgress(this DtStatus @this) - { - return @this == DtStatus.DT_IN_PROGRESS; - } - - public static bool IsPartial(this DtStatus @this) - { - return @this == DtStatus.DT_PARTIAL_RESULT; - } - } -} \ No newline at end of file