Suppose one has something like class foo { int[] x; void bar() { x = []; } }
Does the GC trash the "cache" when calling bar or does it realize that it can use the same memory for x and essentially just shortens the array?
Is it equivalent to setting length = 0?I'm a bit worried that setting a managed array to [] might cause a completely new reallocation, which is unnecessary and undesirable.