Skip to content

Commit b2bf5af

Browse files
Avid29michael-hawker
authored andcommitted
Removed X/Y coords from UVCoord and changed U/V refs to precalculate
1 parent 7d38879 commit b2bf5af

File tree

1 file changed

+13
-38
lines changed

1 file changed

+13
-38
lines changed

components/Segmented/src/EqualPanel.cs

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -162,52 +162,27 @@ private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChan
162162
/// <summary>
163163
/// A struct for mapping X/Y coordinates to an orientation adjusted U/V coordinate system.
164164
/// </summary>
165-
private ref struct UVCoord
165+
private readonly ref struct UVCoord
166166
{
167-
private readonly bool _vertical;
168-
169-
private ref double _x;
170-
private ref double _y;
167+
private readonly ref double _u;
168+
private readonly ref double _v;
171169

172170
public UVCoord(ref double x, ref double y, Orientation orientation)
173171
{
174-
_x = ref x;
175-
_y = ref y;
176-
_vertical = orientation is Orientation.Vertical;
177-
}
178-
179-
public ref double X => ref _x;
180-
181-
public ref double Y => ref _y;
182-
183-
public ref double U
184-
{
185-
get
172+
if (orientation is Orientation.Horizontal)
186173
{
187-
if (_vertical)
188-
{
189-
return ref Y;
190-
}
191-
else
192-
{
193-
return ref X;
194-
}
174+
_u = ref x;
175+
_v = ref y;
195176
}
196-
}
197-
198-
public ref double V
199-
{
200-
get
177+
else
201178
{
202-
if (_vertical)
203-
{
204-
return ref X;
205-
}
206-
else
207-
{
208-
return ref Y;
209-
}
179+
_u = ref y;
180+
_v = ref x;
210181
}
211182
}
183+
184+
public readonly ref double U => ref _u;
185+
186+
public readonly ref double V => ref _v;
212187
}
213188
}

0 commit comments

Comments
 (0)