Skip to content

Commit 7455284

Browse files
authored
Merge branch 'master' into improvement/high-performance-tweaks
2 parents 49b1eba + 130dbe0 commit 7455284

File tree

449 files changed

+6408
-10553
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

449 files changed

+6408
-10553
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,5 +323,5 @@ dotnet_diagnostic.SA1634.severity = none
323323
dotnet_diagnostic.SA1652.severity = none
324324

325325
dotnet_diagnostic.SA1629.severity = none # DocumentationTextMustEndWithAPeriod: Let's enable this rule back when we shift to WinUI3 (v8.x). If we do it now, it would mean more than 400 file changes.
326-
dotnet_diagnostic.SA1413.severity = none # UseTrailingCommasInMultiLineInitializers: This would also mean a lot of changes at the end of all multiline intializers. It's also debatable if we want this or not.
326+
dotnet_diagnostic.SA1413.severity = none # UseTrailingCommasInMultiLineInitializers: This would also mean a lot of changes at the end of all multiline initializers. It's also debatable if we want this or not.
327327
dotnet_diagnostic.SA1314.severity = none # TypeParameterNamesMustBeginWithT: We do have a few templates that don't start with T. We need to double check that changing this is not a breaking change. If not, we can re-enable this.

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
1515
<IsUwpProject Condition="'$(IsDesignProject)' != 'true'">$(MSBuildProjectName.Contains('Uwp'))</IsUwpProject>
1616
<IsSampleProject>$(MSBuildProjectName.Contains('Sample'))</IsSampleProject>
17-
<DefaultTargetPlatformVersion>18362</DefaultTargetPlatformVersion>
18-
<DefaultTargetPlatformMinVersion>16299</DefaultTargetPlatformMinVersion>
17+
<DefaultTargetPlatformVersion>19041</DefaultTargetPlatformVersion>
18+
<DefaultTargetPlatformMinVersion>17763</DefaultTargetPlatformMinVersion>
1919
<PackageOutputPath>$(MSBuildThisFileDirectory)bin\nupkg</PackageOutputPath>
2020
</PropertyGroup>
2121

Directory.Build.targets

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<Choose>
3-
<When Condition="'$(TargetFramework)' == 'uap10.0' or '$(TargetFramework)' == 'uap10.0.16299' or '$(TargetFramework)' == 'native' or '$(TargetFramework)' == 'net461'">
3+
<When Condition="'$(TargetFramework)' == 'uap10.0' or '$(TargetFramework)' == 'uap10.0.17763' or '$(TargetFramework)' == 'native' or '$(TargetFramework)' == 'net461'">
44
<!-- UAP versions for uap10.0 where TPMV isn't implied -->
55
<PropertyGroup>
66
<TargetPlatformVersion>10.0.$(DefaultTargetPlatformVersion).0</TargetPlatformVersion>
@@ -15,9 +15,6 @@
1515
<SDKReference Condition="'$(UseWindowsDesktopSdk)' == 'true' " Include="WindowsDesktop, Version=$(TargetPlatformVersion)">
1616
<Name>Windows Desktop Extensions for the UWP</Name>
1717
</SDKReference>
18-
<SDKReference Condition="'$(UseWindowsMobileSdk)' == 'true' " Include="WindowsMobile, Version=$(TargetPlatformVersion)">
19-
<Name>Windows Mobile Extensions for the UWP</Name>
20-
</SDKReference>
2118
</ItemGroup>
2219
</When>
2320
</Choose>

GazeInputTest/GazeInputTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<AssemblyName>GazeInputTest</AssemblyName>
1212
<DefaultLanguage>en-US</DefaultLanguage>
1313
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
14-
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.18362.0</TargetPlatformVersion>
14+
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.19041.0</TargetPlatformVersion>
1515
<TargetPlatformMinVersion>10.0.17134.0</TargetPlatformMinVersion>
1616
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
1717
<FileAlignment>512</FileAlignment>

GazeInputTest/MainPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
</ToggleButton>
4444
<ProgressBar Grid.Row="1" x:Name="ProgressShow" Maximum="100" />
4545
</Grid>
46-
<TextBlock Grid.Row="2" Grid.Column="0" x:Name="DeviceAvailable" Text="Device availablility not yet detected"/>
46+
<TextBlock Grid.Row="2" Grid.Column="0" x:Name="DeviceAvailable" Text="Device availability not yet detected"/>
4747
<Grid Grid.Row="2" Grid.Column="1">
4848
<Grid.ColumnDefinitions>
4949
<ColumnDefinition/>

Microsoft.Toolkit.HighPerformance/Buffers/MemoryBufferWriter{T}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace Microsoft.Toolkit.HighPerformance.Buffers
1212
{
1313
/// <summary>
14-
/// Represents an utput sink into which <typeparamref name="T"/> data can be written, backed by a <see cref="Memory{T}"/> instance.
14+
/// Represents an output sink into which <typeparamref name="T"/> data can be written, backed by a <see cref="Memory{T}"/> instance.
1515
/// </summary>
1616
/// <typeparam name="T">The type of items to write to the current instance.</typeparam>
1717
/// <remarks>

Microsoft.Toolkit.HighPerformance/Extensions/ReadOnlySpanExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public static ref readonly T DangerousGetLookupReferenceAt<T>(this ReadOnlySpan<
9999
// The result is then negated, producing the value 0xFFFFFFFF
100100
// for valid indices, or 0 otherwise. The generated mask
101101
// is then combined with the original index. This leaves
102-
// the index intact if it was valid, otherwise zeroes it.
102+
// the index intact if it was valid, otherwise zeros it.
103103
// The computed offset is finally used to access the
104104
// lookup table, and it is guaranteed to never go out of
105105
// bounds unless the input span was just empty, which for a

Microsoft.Toolkit.HighPerformance/Helpers/BitHelper.cs

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static bool HasFlag(uint value, int n)
5454
/// decrement the input parameter <paramref name="x"/> to ensure that the range of accepted
5555
/// values fits within the available 32 bits of the lookup table in use.
5656
/// For more info on this optimization technique, see <see href="https://egorbo.com/llvm-range-checks.html"/>.
57-
/// Here is how the code from the lik above would be implemented using this method:
57+
/// Here is how the code from the link above would be implemented using this method:
5858
/// <code>
5959
/// bool IsReservedCharacter(char c)
6060
/// {
@@ -103,6 +103,68 @@ public static bool HasLookupFlag(uint table, int x, int min = 0)
103103
return valid;
104104
}
105105

106+
/// <summary>
107+
/// Checks whether the given value has any bytes that are set to 0.
108+
/// That is, given a <see cref="uint"/> value, which has a total of 4 bytes,
109+
/// it checks whether any of those have all the bits set to 0.
110+
/// </summary>
111+
/// <param name="value">The input value to check.</param>
112+
/// <returns>Whether <paramref name="value"/> has any bytes set to 0.</returns>
113+
/// <remarks>
114+
/// This method contains no branches.
115+
/// For more background on this subject, see <see href="https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord"/>.
116+
/// </remarks>
117+
[Pure]
118+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
119+
public static bool HasZeroByte(uint value)
120+
{
121+
return ((value - 0x0101_0101u) & ~value & 0x8080_8080u) != 0;
122+
}
123+
124+
/// <summary>
125+
/// Checks whether the given value has any bytes that are set to 0.
126+
/// This method mirrors <see cref="HasZeroByte(uint)"/>, but with <see cref="ulong"/> values.
127+
/// </summary>
128+
/// <param name="value">The input value to check.</param>
129+
/// <returns>Whether <paramref name="value"/> has any bytes set to 0.</returns>
130+
[Pure]
131+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
132+
public static bool HasZeroByte(ulong value)
133+
{
134+
return ((value - 0x0101_0101_0101_0101ul) & ~value & 0x8080_8080_8080_8080ul) != 0;
135+
}
136+
137+
/// <summary>
138+
/// Checks whether a byte in the input <see cref="uint"/> value matches a target value.
139+
/// </summary>
140+
/// <param name="value">The input value to check.</param>
141+
/// <param name="target">The target byte to look for.</param>
142+
/// <returns>Whether <paramref name="value"/> has any bytes set to <paramref name="target"/>.</returns>
143+
/// <remarks>
144+
/// This method contains no branches.
145+
/// For more info, see <see href="https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord"/>.
146+
/// </remarks>
147+
[Pure]
148+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
149+
public static bool HasByteEqualTo(uint value, byte target)
150+
{
151+
return HasZeroByte(value ^ (0x0101_0101u * target));
152+
}
153+
154+
/// <summary>
155+
/// Checks whether a byte in the input <see cref="uint"/> value matches a target value.
156+
/// This method mirrors <see cref="HasByteEqualTo(uint,byte)"/>, but with <see cref="ulong"/> values.
157+
/// </summary>
158+
/// <param name="value">The input value to check.</param>
159+
/// <param name="target">The target byte to look for.</param>
160+
/// <returns>Whether <paramref name="value"/> has any bytes set to <paramref name="target"/>.</returns>
161+
[Pure]
162+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
163+
public static bool HasByteEqualTo(ulong value, byte target)
164+
{
165+
return HasZeroByte(value ^ (0x0101_0101_0101_0101u * target));
166+
}
167+
106168
/// <summary>
107169
/// Sets a bit to a specified value.
108170
/// </summary>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static unsafe int GetDjb2LikeByteHash(ref byte r0, IntPtr length)
105105
// and the final loop to combine the partial hash values.
106106
// Note that even when we use the vectorized path we don't need to do
107107
// any preprocessing to try to get memory aligned, as that would cause
108-
// the hashcodes to potentially be different for the same data.
108+
// the hash codes to potentially be different for the same data.
109109
if (Vector.IsHardwareAccelerated &&
110110
(byte*)length >= (byte*)(Vector<byte>.Count << 3))
111111
{

Microsoft.Toolkit.HighPerformance/NullableRef{T}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public bool HasValue
5959
get
6060
{
6161
// We know that the span will always have a length of either
62-
// 1 or 0, se instead of using a cmp instruction and setting the
62+
// 1 or 0, so instead of using a cmp instruction and setting the
6363
// zero flag to produce our boolean value, we can just cast
6464
// the length to byte without overflow checks (doing a cast will
6565
// also account for the byte endianness of the current system),

0 commit comments

Comments
 (0)