From 554da102b4319bb7c6703988308f0cadce763a95 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 1 Jul 2022 19:49:31 +0800 Subject: [PATCH] apply the hint by rider. --- osu.Framework/Utils/ConvexPolygonClipper.cs | 2 +- osu.Framework/Utils/Interpolation.cs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/osu.Framework/Utils/ConvexPolygonClipper.cs b/osu.Framework/Utils/ConvexPolygonClipper.cs index a0de4e79e7..4af741e285 100644 --- a/osu.Framework/Utils/ConvexPolygonClipper.cs +++ b/osu.Framework/Utils/ConvexPolygonClipper.cs @@ -93,7 +93,7 @@ public Span Clip(in Span buffer) if (validClipEdges < 3) return Span.Empty; - return buffer.Slice(0, inputCount); + return buffer[..inputCount]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/osu.Framework/Utils/Interpolation.cs b/osu.Framework/Utils/Interpolation.cs index 3e434835c9..773f6efa25 100644 --- a/osu.Framework/Utils/Interpolation.cs +++ b/osu.Framework/Utils/Interpolation.cs @@ -28,7 +28,7 @@ public static class Interpolation /// The exponent of the exponential. An exponent of 0 results in the start values, whereas larger exponents make the result converge to the final value. public static double Damp(double start, double final, double @base, double exponent) { - if (@base < 0 || @base > 1) + if (@base is < 0 or > 1) throw new ArgumentOutOfRangeException(nameof(@base), $"{nameof(@base)} has to lie in [0,1], but is {@base}."); return Lerp(start, final, 1 - Math.Pow(@base, exponent)); @@ -390,9 +390,7 @@ static GenericInterpolation() FUNCTION = (InterpolationFunc)valueAtMethod.CreateDelegate(typeof(InterpolationFunc)); else { - var typeRef = FormatterServices.GetSafeUninitializedObject(typeof(TValue)) as IInterpolable; - - if (typeRef == null) + if (FormatterServices.GetSafeUninitializedObject(typeof(TValue)) is not IInterpolable typeRef) throw new NotSupportedException($"Type {typeof(TValue)} has no interpolation function. Implement the interface {typeof(IInterpolable)} interface on the object."); FUNCTION = typeRef.ValueAt;