Skip to content

Commit 8897408

Browse files
committed
Merge branch 'master' into test-TextBoxMask
2 parents 150282d + 001c5c4 commit 8897408

File tree

5 files changed

+72
-59
lines changed

5 files changed

+72
-59
lines changed

Microsoft.Toolkit.HighPerformance/Helpers/Internals/SpanHelper.Count.cs

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ public static nint Count<T>(ref T r0, nint length, T value)
7979
/// Implements <see cref="Count{T}"/> with a sequential search.
8080
/// </summary>
8181
[Pure]
82-
#if NETCOREAPP3_1
83-
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
84-
#endif
8582
private static nint CountSequential<T>(ref T r0, nint length, T value)
8683
where T : IEquatable<T>
8784
{
@@ -132,9 +129,6 @@ private static nint CountSequential<T>(ref T r0, nint length, T value)
132129
/// Implements <see cref="Count{T}"/> with a vectorized search.
133130
/// </summary>
134131
[Pure]
135-
#if NETCOREAPP3_1
136-
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
137-
#endif
138132
private static nint CountSimd<T>(ref T r0, nint length, T value)
139133
where T : unmanaged, IEquatable<T>
140134
{
@@ -161,6 +155,67 @@ private static nint CountSimd<T>(ref T r0, nint length, T value)
161155

162156
var partials = Vector<T>.Zero;
163157

158+
// Unrolled vectorized loop, with 8 unrolled iterations. We only run this when the
159+
// current type T is at least 2 bytes in size, otherwise the average chunk length
160+
// would always be too small to be able to trigger the unrolled loop, and the overall
161+
// performance would just be slightly worse due to the additional conditional branches.
162+
if (typeof(T) != typeof(sbyte))
163+
{
164+
while (chunkLength >= Vector<T>.Count * 8)
165+
{
166+
ref T ri0 = ref Unsafe.Add(ref r0, offset + (Vector<T>.Count * 0));
167+
var vi0 = Unsafe.As<T, Vector<T>>(ref ri0);
168+
var ve0 = Vector.Equals(vi0, vc);
169+
170+
partials -= ve0;
171+
172+
ref T ri1 = ref Unsafe.Add(ref r0, offset + (Vector<T>.Count * 1));
173+
var vi1 = Unsafe.As<T, Vector<T>>(ref ri1);
174+
var ve1 = Vector.Equals(vi1, vc);
175+
176+
partials -= ve1;
177+
178+
ref T ri2 = ref Unsafe.Add(ref r0, offset + (Vector<T>.Count * 2));
179+
var vi2 = Unsafe.As<T, Vector<T>>(ref ri2);
180+
var ve2 = Vector.Equals(vi2, vc);
181+
182+
partials -= ve2;
183+
184+
ref T ri3 = ref Unsafe.Add(ref r0, offset + (Vector<T>.Count * 3));
185+
var vi3 = Unsafe.As<T, Vector<T>>(ref ri3);
186+
var ve3 = Vector.Equals(vi3, vc);
187+
188+
partials -= ve3;
189+
190+
ref T ri4 = ref Unsafe.Add(ref r0, offset + (Vector<T>.Count * 4));
191+
var vi4 = Unsafe.As<T, Vector<T>>(ref ri4);
192+
var ve4 = Vector.Equals(vi4, vc);
193+
194+
partials -= ve4;
195+
196+
ref T ri5 = ref Unsafe.Add(ref r0, offset + (Vector<T>.Count * 5));
197+
var vi5 = Unsafe.As<T, Vector<T>>(ref ri5);
198+
var ve5 = Vector.Equals(vi5, vc);
199+
200+
partials -= ve5;
201+
202+
ref T ri6 = ref Unsafe.Add(ref r0, offset + (Vector<T>.Count * 6));
203+
var vi6 = Unsafe.As<T, Vector<T>>(ref ri6);
204+
var ve6 = Vector.Equals(vi6, vc);
205+
206+
partials -= ve6;
207+
208+
ref T ri7 = ref Unsafe.Add(ref r0, offset + (Vector<T>.Count * 7));
209+
var vi7 = Unsafe.As<T, Vector<T>>(ref ri7);
210+
var ve7 = Vector.Equals(vi7, vc);
211+
212+
partials -= ve7;
213+
214+
chunkLength -= Vector<T>.Count * 8;
215+
offset += Vector<T>.Count * 8;
216+
}
217+
}
218+
164219
while (chunkLength >= Vector<T>.Count)
165220
{
166221
ref T ri = ref Unsafe.Add(ref r0, offset);
@@ -242,28 +297,22 @@ private static nint CountSimd<T>(ref T r0, nint length, T value)
242297
private static unsafe nint GetUpperBound<T>()
243298
where T : unmanaged
244299
{
245-
if (typeof(T) == typeof(byte) ||
246-
typeof(T) == typeof(sbyte) ||
247-
typeof(T) == typeof(bool))
300+
if (typeof(T) == typeof(sbyte))
248301
{
249302
return sbyte.MaxValue;
250303
}
251304

252-
if (typeof(T) == typeof(char) ||
253-
typeof(T) == typeof(ushort) ||
254-
typeof(T) == typeof(short))
305+
if (typeof(T) == typeof(short))
255306
{
256307
return short.MaxValue;
257308
}
258309

259-
if (typeof(T) == typeof(int) ||
260-
typeof(T) == typeof(uint))
310+
if (typeof(T) == typeof(int))
261311
{
262312
return int.MaxValue;
263313
}
264314

265-
if (typeof(T) == typeof(long) ||
266-
typeof(T) == typeof(ulong))
315+
if (typeof(T) == typeof(long))
267316
{
268317
if (sizeof(nint) == sizeof(int))
269318
{

Microsoft.Toolkit.HighPerformance/Helpers/Internals/SpanHelper.Hash.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ internal static partial class SpanHelper
2121
/// <param name="length">The number of items to hash.</param>
2222
/// <returns>The Djb2 value for the input sequence of items.</returns>
2323
[Pure]
24-
#if NETCOREAPP3_1
25-
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
26-
#endif
2724
public static int GetDjb2HashCode<T>(ref T r0, nint length)
2825
where T : notnull
2926
{
@@ -87,9 +84,6 @@ public static int GetDjb2HashCode<T>(ref T r0, nint length)
8784
/// faster than <see cref="GetDjb2HashCode{T}"/>, as it can parallelize much of the workload.
8885
/// </remarks>
8986
[Pure]
90-
#if NETCOREAPP3_1
91-
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
92-
#endif
9387
public static unsafe int GetDjb2LikeByteHash(ref byte r0, nint length)
9488
{
9589
int hash = 5381;

Microsoft.Toolkit.Uwp.Notifications/Microsoft.Toolkit.Uwp.Notifications.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<Project Sdk="MSBuild.Sdk.Extras">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard1.4;uap10.0;native;net461;netcoreapp3.1</TargetFrameworks>
4+
<!--<TargetFrameworks>netstandard1.4;uap10.0;native;net461;netcoreapp3.1</TargetFrameworks>-->
5+
<!-- Removed 'native' target to unblock CI on VS 16.8, tied to changes breaking workaround for https://github.com/NuGet/Home/issues/5154 -->
6+
<TargetFrameworks>netstandard1.4;uap10.0;net461;netcoreapp3.1</TargetFrameworks>
57
<DefineConstants>$(DefineConstants);NETFX_CORE</DefineConstants>
68
<Title>Windows Community Toolkit Notifications</Title>
79
<Description>

Microsoft.Toolkit.Uwp.UI.Animations/Behaviors/StickyHeaderBehavior.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Windows.UI.Xaml.Controls;
1212
using Windows.UI.Xaml.Hosting;
1313
using Windows.UI.Xaml.Input;
14+
using Windows.UI.Xaml.Media;
1415

1516
namespace Microsoft.Toolkit.Uwp.UI.Animations.Behaviors
1617
{
@@ -238,7 +239,9 @@ private void ScrollViewer_GotFocus(object sender, RoutedEventArgs e)
238239
focusedElement = FocusManager.GetFocusedElement();
239240
}
240241

241-
if (focusedElement is UIElement element)
242+
// To prevent Popups (Flyouts...) from triggering the autoscroll, we check if the focused element has a valid parent.
243+
// Popups have no parents, whereas a normal Item would have the ListView as a parent.
244+
if (focusedElement is UIElement element && VisualTreeHelper.GetParent(element) != null)
242245
{
243246
FrameworkElement header = (FrameworkElement)HeaderElement;
244247

Windows Community Toolkit.sln

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Toolkit.Uwp.Notif
4343
EndProject
4444
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests.Notifications.NetCore", "UnitTests\UnitTests.Notifications.NetCore\UnitTests.Notifications.NetCore.csproj", "{94994424-5F60-4CD8-ABA2-101779066208}"
4545
EndProject
46-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests.Notifications.WinRT", "UnitTests\UnitTests.Notifications.WinRT\UnitTests.Notifications.WinRT.csproj", "{EFA96B3C-857E-4659-B942-6BEF7719F4CA}"
47-
ProjectSection(ProjectDependencies) = postProject
48-
{97EE849B-403C-490E-80ED-D19D7CC153FD} = {97EE849B-403C-490E-80ED-D19D7CC153FD}
49-
EndProjectSection
50-
EndProject
5146
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CFA75BE0-5A44-45DE-8114-426A605B062B}"
5247
ProjectSection(SolutionItems) = preProject
5348
.editorconfig = .editorconfig
@@ -151,7 +146,6 @@ Global
151146
UnitTests\UnitTests.Notifications.Shared\UnitTests.Notifications.Shared.projitems*{bab1caf4-c400-4a7f-a987-c576de63cffd}*SharedItemsImports = 4
152147
UITests\UITests.Tests.Shared\UITests.Tests.Shared.projitems*{c8182ef0-77fb-4b43-a588-c71748a309c7}*SharedItemsImports = 5
153148
UnitTests\UnitTests.HighPerformance.Shared\UnitTests.HighPerformance.Shared.projitems*{d9bdbc68-3d0a-47fc-9c88-0bf769101644}*SharedItemsImports = 5
154-
UnitTests\UnitTests.Notifications.Shared\UnitTests.Notifications.Shared.projitems*{efa96b3c-857e-4659-b942-6bef7719f4ca}*SharedItemsImports = 4
155149
EndGlobalSection
156150
GlobalSection(SolutionConfigurationPlatforms) = preSolution
157151
Debug|Any CPU = Debug|Any CPU
@@ -489,34 +483,6 @@ Global
489483
{94994424-5F60-4CD8-ABA2-101779066208}.Release|x64.Build.0 = Release|Any CPU
490484
{94994424-5F60-4CD8-ABA2-101779066208}.Release|x86.ActiveCfg = Release|Any CPU
491485
{94994424-5F60-4CD8-ABA2-101779066208}.Release|x86.Build.0 = Release|Any CPU
492-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Debug|Any CPU.ActiveCfg = Debug|x86
493-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Debug|Any CPU.Build.0 = Debug|x86
494-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Debug|ARM.ActiveCfg = Debug|ARM
495-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Debug|ARM.Build.0 = Debug|ARM
496-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Debug|ARM.Deploy.0 = Debug|ARM
497-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Debug|ARM64.ActiveCfg = Debug|ARM64
498-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Debug|ARM64.Build.0 = Debug|ARM64
499-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Debug|ARM64.Deploy.0 = Debug|ARM64
500-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Debug|x64.ActiveCfg = Debug|x64
501-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Debug|x64.Build.0 = Debug|x64
502-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Debug|x64.Deploy.0 = Debug|x64
503-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Debug|x86.ActiveCfg = Debug|x86
504-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Debug|x86.Build.0 = Debug|x86
505-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Debug|x86.Deploy.0 = Debug|x86
506-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Release|Any CPU.ActiveCfg = Release|x86
507-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Release|Any CPU.Build.0 = Release|x86
508-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Release|ARM.ActiveCfg = Release|ARM
509-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Release|ARM.Build.0 = Release|ARM
510-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Release|ARM.Deploy.0 = Release|ARM
511-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Release|ARM64.ActiveCfg = Release|ARM64
512-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Release|ARM64.Build.0 = Release|ARM64
513-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Release|ARM64.Deploy.0 = Release|ARM64
514-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Release|x64.ActiveCfg = Release|x64
515-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Release|x64.Build.0 = Release|x64
516-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Release|x64.Deploy.0 = Release|x64
517-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Release|x86.ActiveCfg = Release|x86
518-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Release|x86.Build.0 = Release|x86
519-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA}.Release|x86.Deploy.0 = Release|x86
520486
{7AEFC959-ED7C-4D96-9E92-72609B40FBE0}.Debug|Any CPU.ActiveCfg = Debug|x86
521487
{7AEFC959-ED7C-4D96-9E92-72609B40FBE0}.Debug|Any CPU.Build.0 = Debug|x86
522488
{7AEFC959-ED7C-4D96-9E92-72609B40FBE0}.Debug|ARM.ActiveCfg = Debug|x86
@@ -1031,7 +997,6 @@ Global
1031997
{BAB1CAF4-C400-4A7F-A987-C576DE63CFFD} = {9333C63A-F64F-4797-82B3-017422668A5D}
1032998
{1AE2CB5C-58A0-4F12-8E6F-2CD4AAADB34C} = {9AD30620-667D-433C-9961-8D885EE7B762}
1033999
{94994424-5F60-4CD8-ABA2-101779066208} = {9333C63A-F64F-4797-82B3-017422668A5D}
1034-
{EFA96B3C-857E-4659-B942-6BEF7719F4CA} = {9333C63A-F64F-4797-82B3-017422668A5D}
10351000
{7AEFC959-ED7C-4D96-9E92-72609B40FBE0} = {F1AFFFA7-28FE-4770-BA48-10D76F3E59BC}
10361001
{6BD0BA4A-DE6D-3E87-8F83-63518C31ECD1} = {F1AFFFA7-28FE-4770-BA48-10D76F3E59BC}
10371002
{A122EA02-4DE7-413D-BFBF-AF7DFC668DD6} = {B30036C4-D514-4E5B-A323-587A061772CE}

0 commit comments

Comments
 (0)