fix: Cleans up LINQ calls. (#965)

- [X] Removes several `ToList()` uses with `PooledRefQueue`
- [X] Adds a `PeekRandom` to PooledRefQueue
- [X] Updates EV/BS so they dispel each other in a more efficient manner.
- [X] Fixes Firebomb so it works like a normal firefield.
- [X] Fixes field spells so they aren't unnecessarily using a Point3D ref more than necessary.
- [X] Removes extra allocation in campfire by using reverse loop.
- [X] Removes other LINQ calls that aren't needed.
This commit is contained in:
Kamron Batman 2022-03-20 19:20:54 -07:00 committed by GitHub
parent daf89686d1
commit 23532db603
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 585 additions and 447 deletions

View file

@ -14,7 +14,7 @@ namespace Benchmarks.EntitiesSelectors
public class MapEntitiesSelectors
{
private static readonly Sector sector = new();
private static readonly Point3D[] locations = new[] { new Point3D(0, 0, 0), new Point3D(50, 50, 0) };
private static readonly Point3D[] locations = { new Point3D(0, 0, 0), new Point3D(50, 50, 0) };
public static Rectangle2D[] BoundsArray() => new[]
{
@ -501,8 +501,8 @@ namespace Benchmarks.EntitiesSelectors
public class Sector
{
public List<BItem> BItems { get; set; } = new List<BItem>();
public List<Mobile> Mobiles { get; set; } = new List<Mobile>();
public List<BItem> BItems { get; set; } = new();
public List<Mobile> Mobiles { get; set; } = new();
}
public struct BItemWhereHyper : NetFabric.Hyperlinq.IFunction<BItem, bool>

View file

@ -20,7 +20,7 @@ namespace Benchmarks.ItemSelectors
public class MapItemSelectors
{
private static readonly Sector sector = new();
private static readonly Point3D[] locations = new[] { new Point3D(0, 0, 0), new Point3D(50, 50, 0) };
private static readonly Point3D[] locations = { new Point3D(0, 0, 0), new Point3D(50, 50, 0) };
public static Rectangle2D[] BoundsArray() => new[]
{
@ -352,7 +352,7 @@ namespace Benchmarks.ItemSelectors
public class Sector
{
public List<BItem> BItems { get; set; } = new List<BItem>();
public List<BItem> BItems { get; set; } = new();
}
public struct BItemWhere<T> : StructLinq.IFunction<BItem, bool> where T : BItem

View file

@ -2,7 +2,6 @@ using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using NetFabric.Hyperlinq;
using Server;
using StructLinq;
using System;
using System.Collections.Generic;
using System.Linq;
@ -15,7 +14,7 @@ namespace Benchmarks.MobileSelectors
public class MapMobileSelectors
{
private static readonly Sector sector = new();
private static readonly Point3D[] locations = new[] { new Point3D(0, 0, 0), new Point3D(50, 50, 0) };
private static readonly Point3D[] locations = { new Point3D(0, 0, 0), new Point3D(50, 50, 0) };
public static Rectangle2D[] BoundsArray() => new[]
{
@ -224,10 +223,10 @@ namespace Benchmarks.MobileSelectors
{
public MobileDerived(Point3D location) : base(location) { }
}
public class Sector
{
public List<Mobile> Mobiles { get; set; } = new List<Mobile>();
public List<Mobile> Mobiles { get; set; } = new();
}
public struct MobileWhereHyper<T> : NetFabric.Hyperlinq.IFunction<Mobile, bool> where T : Mobile

View file

@ -2,7 +2,6 @@ using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using NetFabric.Hyperlinq;
using Server;
using StructLinq;
using System;
using System.Collections.Generic;
using System.Linq;
@ -15,7 +14,7 @@ namespace Benchmarks.MultiSelectors
public class MapMultiSelectors
{
private static readonly Sector sector = new();
private static readonly Point3D[] locations = new[] { new Point3D(0, 0, 0), new Point3D(50, 50, 0) };
private static readonly Point3D[] locations = { new Point3D(0, 0, 0), new Point3D(50, 50, 0) };
public static Rectangle2D[] BoundsArray() => new[]
{
@ -291,10 +290,10 @@ namespace Benchmarks.MultiSelectors
public class Sector
{
public List<BaseMulti> Multis { get; set; } = new List<BaseMulti>();
public List<BaseMulti> Multis { get; set; } = new();
}
public struct MultiWhereHyper : NetFabric.Hyperlinq.IFunction<BaseMulti, bool>
public struct MultiWhereHyper : IFunction<BaseMulti, bool>
{
private readonly Rectangle2D bounds;

View file

@ -1,8 +1,6 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using NetFabric.Hyperlinq;
using Server;
using StructLinq;
using System;
using System.Collections.Generic;
using System.Linq;
@ -14,7 +12,7 @@ namespace Benchmarks.MultiTilesSelectors
public class MapMultiTilesSelectors
{
private static readonly Sector sector = new();
private static readonly Point3D[] locations = new[] { new Point3D(0, 0, 0), new Point3D(50, 50, 0) };
private static readonly Point3D[] locations = { new Point3D(0, 0, 0), new Point3D(50, 50, 0) };
public static Rectangle2D[] BoundsArray() => new[]
{
@ -55,7 +53,7 @@ namespace Benchmarks.MultiTilesSelectors
return toRet;
}
[Benchmark(Baseline = true)]
public int SelectMultiTilesLinq()
{
@ -347,6 +345,6 @@ namespace Benchmarks.MultiTilesSelectors
public class Sector
{
public List<BaseMulti> Multis { get; set; } = new List<BaseMulti>();
public List<BaseMulti> Multis { get; set; } = new();
}
}