diff options
author | therzok <marius.ungureanu@xamarin.com> | 2019-07-21 06:26:11 +0300 |
---|---|---|
committer | therzok <marius.ungureanu@xamarin.com> | 2019-07-21 06:41:52 +0300 |
commit | 7553da64684046e7a92b5695ef5d1cd70f81aff7 (patch) | |
tree | b2c26886bcaa4286e1fa497be08682681b96941d /main/src/core/MonoDevelop.Core | |
parent | acd388255b89d19ccf8247ceb64db382d7f777cd (diff) |
[Core] Add an overload for Array which should fix most usages of IEnumerable.Contains on arrays
The new method shadows the old one, so we get quite a few performance improvements, most in the project
model
Diffstat (limited to 'main/src/core/MonoDevelop.Core')
-rw-r--r-- | main/src/core/MonoDevelop.Core/CoreExtensions.Array.cs | 33 | ||||
-rw-r--r-- | main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj | 1 |
2 files changed, 34 insertions, 0 deletions
diff --git a/main/src/core/MonoDevelop.Core/CoreExtensions.Array.cs b/main/src/core/MonoDevelop.Core/CoreExtensions.Array.cs new file mode 100644 index 0000000000..efa5f2155c --- /dev/null +++ b/main/src/core/MonoDevelop.Core/CoreExtensions.Array.cs @@ -0,0 +1,33 @@ +// +// CoreExtensions.Array.cs +// +// Author: +// Marius Ungureanu <maungu@microsoft.com> +// +// Copyright (c) 2019 Microsoft Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +namespace System +{ + public static partial class CoreExtensions + { + internal static bool Contains<T> (this T [] arr, T value) => Array.IndexOf (arr, value) != -1; + } +} diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj index c86fd60eab..e1ec35552d 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj @@ -740,6 +740,7 @@ <Compile Include="CoreExtensions.IEnumerable.cs" /> <Compile Include="CoreExtensions.Memoize.cs" /> <Compile Include="CoreExtensions.EventHandlers.cs" /> + <Compile Include="CoreExtensions.Array.cs" /> </ItemGroup> <ItemGroup> <None Include="BuildVariables.cs.in" /> |