What is the correct way to clear an array in Haxe?

Viewed 1456

What would be the most performant way to clear an array in Haxe? Currently I am just assigning an empty array to the variable.

I found this on the Internet:

public static function clear(arr:Array<Dynamic>) {
    #if cpp
    arr.splice(0, arr.length);
    #else
    untyped arr.length = 0;
    #end
}

Is this the best way? I am concerned with two targets, JS and CPP.

1 Answers
Related