Browse Source

Use Array.Resize when growing ArrayInstance (#1997)

Marko Lahma 9 months ago
parent
commit
7849416d32
1 changed files with 1 additions and 3 deletions
  1. 1 3
      Jint/Native/Array/ArrayInstance.cs

+ 1 - 3
Jint/Native/Array/ArrayInstance.cs

@@ -951,9 +951,7 @@ public class ArrayInstance : ObjectInstance, IEnumerable<JsValue>
         }
         }
 
 
         // need to grow
         // need to grow
-        var newArray = new JsValue[capacity];
-        System.Array.Copy(dense, newArray, dense.Length);
-        _dense = newArray;
+        System.Array.Resize(ref _dense, (int) capacity);
     }
     }
 
 
     public JsValue[] ToArray()
     public JsValue[] ToArray()