ModernUO/Projects/UOContent/Commands
Kamron Batman a4cabe2fa4
fix: Optimizes FindItemsByType by removing allocations. (#1515)
### Summary
Container enumeration is in dire need of optimization. Thanks to @stefanomerotta for initiating this work with PR #1443. This PR handles a small part of what Stefan started. Also included are some bug fixes.

### Method Signatures

```cs
// Use with foreach without moving/deleting items
FindItemsByTypeEnumerator<T> FindItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use with foreach when moving/deleting items
QueuedItemsEnumerator<T> EnumerateItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use when iterating multiple times or queuing
PooledRefQueue<T> QueueItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use when iterating multiples times or manipulating elements without traversing
PooledRefList<T> ListItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)
```

* `FindItemsByType<T>` has changed from returning `List<T>` to `FindItemsByTypeEnumerator<T>` - This method is not safe to use in situations where an item may get consumed, deleted, or moved.

* `EnumerateItemsByType<T>` was added as a safe way to iterate and manipulate items.
  * **Note**: EnumerateItemsByType will _completely traverse the container_ before iteration starts because it uses `QueueItemsByType` under the hood.

* `QueueItemsByType<T>`  and `ListItemsByType<T>` was added to return a queue or list of items to iterate multiple times and manipulate the items. This isn't the most efficient since it uses a predicate and can result in 2 or 3 total iterations unnecessarily.

### Bug Fixes
- [X] Fishing had an error in the random check that may have caused slight bias.
2023-09-28 19:36:45 -07:00
..
Generic fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Object Creation chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
Attributes.cs Cleanup & Fixes for .NET 5 (#309) 2020-11-15 10:03:50 -08:00
Batch.cs fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283) 2022-11-28 19:58:12 -08:00
BoundingBoxPicker.cs fix: Cleans up Point checks and removes statics (#966) 2022-03-20 23:15:59 -07:00
DragEffects.cs fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283) 2022-11-28 19:58:12 -08:00
Dupe.cs fix: Fixes PlayerVendor customizations not working due to constructor issues (#1451) 2023-08-10 19:24:45 -07:00
ExportWSC.cs fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283) 2022-11-28 19:58:12 -08:00
Handlers.cs fix: Fixes stabled, abilities targeting self, and unsummon memory leak (#1418) 2023-07-03 09:45:22 -07:00
HelpInfo.cs feat: Adds StaffAccess and ResetStaffDress commands (#895) 2021-12-27 01:27:15 -08:00
LocationCommand.cs chore: Cleans up pattern checks. (#892) 2021-12-24 15:53:59 -08:00
Logging.cs fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283) 2022-11-28 19:58:12 -08:00
Profiling.cs fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283) 2022-11-28 19:58:12 -08:00
Properties.cs feat: Customize expansion and set maps on first boot (#1425) 2023-07-31 20:46:49 -07:00
ResetRng.cs fix: Fixes typo in ResetRng command (#1211) 2022-10-27 23:29:51 -07:00
ResetStaffDress.cs fix: Codegens suits and adds StaffRobe to replace the others (#1468) 2023-08-23 20:25:54 -07:00
ShardTime.cs feat: Adds StaffAccess and ResetStaffDress commands (#895) 2021-12-27 01:27:15 -08:00
SignParser.cs fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283) 2022-11-28 19:58:12 -08:00
Skills.cs fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283) 2022-11-28 19:58:12 -08:00
SkillsMenu.cs feat: Adds StaffAccess and ResetStaffDress commands (#895) 2021-12-27 01:27:15 -08:00
StaffAccess.cs fix: Fixes setting staff access (#899) 2021-12-27 19:38:03 -08:00
VisibilityList.cs fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283) 2022-11-28 19:58:12 -08:00
Wipe.cs fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283) 2022-11-28 19:58:12 -08:00