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:
parent
daf89686d1
commit
23532db603
40 changed files with 585 additions and 447 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue