We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maybe it can be optimized to work like Array<T> without allocating iterator objects here? Blocks optimization point of #11148
Array<T>
using Main; class Main { static function main() new Main(); final nums = [1, 2, 3]; public function new() { final foo = nums.inlineExists(item -> item == 1); trace(foo); final foo2 = nums.inlineArrExists(item -> item == 1); trace(foo2); } public static inline function inlineExists<T>(it:Iterable<T>, f:(item:T) -> Bool):Bool { var result = false; for (v in it) { if (f(v)) { result = true; break; } } return result; } public static inline function inlineArrExists<T>(it:Array<T>, f:(item:T) -> Bool):Bool { var result = false; for (v in it) { if (f(v)) { result = true; break; } } return result; } }
Js output:
this.nums = [1,2,3]; var result = false; var v = $getIterator(this.nums); while(v.hasNext()) if(v.next() == 1) { result = true; break; } console.log("src/Main.hx:9:",result); var it = this.nums; var result = false; var _g = 0; while(_g < it.length) if(it[_g++] == 1) { result = true; break; } console.log("src/Main.hx:11:",result);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Maybe it can be optimized to work like
Array<T>
without allocating iterator objects here?Blocks optimization point of #11148
Js output:
The text was updated successfully, but these errors were encountered: