Skip to content

Commit 4f39bb0

Browse files
committed
[jvm] optimize Array.resize(0)
I see spliceVoid in some benchmarks for this.
1 parent 2606dc7 commit 4f39bb0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

std/jvm/_std/Array.hx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,10 @@ import java.lang.System;
418418
}
419419

420420
public function resize(len:Int):Void {
421-
if (length < len) {
421+
if (len == 0) {
422+
this.length = 0;
423+
this.__a = new NativeArray(0);
424+
} else if (length < len) {
422425
if (__a.length < len) {
423426
var newArr = new NativeArray<T>(len);
424427
if (length > 0)

0 commit comments

Comments
 (0)