From 041ffd55e9d8569494d7684e1d75f38efe415ba5 Mon Sep 17 00:00:00 2001 From: Redmoogle Date: Wed, 26 Nov 2025 15:49:29 -0500 Subject: [PATCH 1/2] Free speedups --- OpenDreamRuntime/DreamValue.cs | 8 +++++--- OpenDreamRuntime/Objects/Types/DreamList.cs | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/OpenDreamRuntime/DreamValue.cs b/OpenDreamRuntime/DreamValue.cs index 2c4deecd50..efa419c6b1 100644 --- a/OpenDreamRuntime/DreamValue.cs +++ b/OpenDreamRuntime/DreamValue.cs @@ -455,11 +455,13 @@ public bool Equals(DreamValue other) { case DreamValueType.DreamObject: { Debug.Assert(_refValue is DreamObject or null, "Failed to cast _refValue to DreamObject"); Debug.Assert(other._refValue is DreamObject or null, "Failed to cast other._refValue to DreamObject"); - if (_refValue != null && Unsafe.As(_refValue).Deleted) + var thisObj = Unsafe.As(_refValue); + var otherObj = Unsafe.As(other._refValue); + if (thisObj != null && thisObj.Deleted == true) _refValue = null; - if (other._refValue != null && Unsafe.As(other._refValue).Deleted) + if (otherObj != null && otherObj.Deleted == true) other._refValue = null; - break; + return thisObj == otherObj; } } diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 737bd22083..1c98194ba2 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -205,7 +205,9 @@ public virtual void AddValue(DreamValue value) { //Does not include associations public virtual bool ContainsValue(DreamValue value) { - for (int i = 0; i < _values.Count; i++) { + var count = _values.Count; + + for (int i = 0; i < count; i++) { if (_values[i].Equals(value)) return true; } From c2e9daabc91d12e5e123bfab8fb6a5d4df7a1974 Mon Sep 17 00:00:00 2001 From: Redmoogle Date: Wed, 26 Nov 2025 16:14:59 -0500 Subject: [PATCH 2/2] Fix comparison --- OpenDreamRuntime/DreamValue.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenDreamRuntime/DreamValue.cs b/OpenDreamRuntime/DreamValue.cs index efa419c6b1..df51839060 100644 --- a/OpenDreamRuntime/DreamValue.cs +++ b/OpenDreamRuntime/DreamValue.cs @@ -457,10 +457,16 @@ public bool Equals(DreamValue other) { Debug.Assert(other._refValue is DreamObject or null, "Failed to cast other._refValue to DreamObject"); var thisObj = Unsafe.As(_refValue); var otherObj = Unsafe.As(other._refValue); - if (thisObj != null && thisObj.Deleted == true) + if (thisObj != null && thisObj.Deleted) { _refValue = null; - if (otherObj != null && otherObj.Deleted == true) + thisObj = null; + } + + if (otherObj != null && otherObj.Deleted) { other._refValue = null; + otherObj = null; + } + return thisObj == otherObj; } }