Skip to content

Commit ee782ac

Browse files
Improve vector transform short circuit
1 parent 0210f48 commit ee782ac

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/ImageSharp.Web/ExifOrientationUtilities.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

4+
using System;
45
using System.Numerics;
56
using System.Runtime.CompilerServices;
67
using SixLabors.ImageSharp.Metadata.Profiles.Exif;
@@ -25,8 +26,9 @@ public static class ExifOrientationUtilities
2526
/// </returns>
2627
public static Vector2 Transform(Vector2 position, Vector2 min, Vector2 max, ushort orientation)
2728
{
28-
if (orientation is >= ExifOrientationMode.Unknown and <= ExifOrientationMode.TopLeft)
29+
if (orientation is <= ExifOrientationMode.TopLeft or > ExifOrientationMode.LeftBottom)
2930
{
31+
// Short circuit orientations that are not transformed below
3032
return position;
3133
}
3234

@@ -62,7 +64,7 @@ public static Vector2 Transform(Vector2 position, Vector2 min, Vector2 max, usho
6264
builder.AppendRotationDegrees(90);
6365
break;
6466
default:
65-
return position;
67+
break;
6668
}
6769

6870
Matrix3x2 matrix = builder.BuildMatrix(size);

0 commit comments

Comments
 (0)