Performance of empty function on Dart
1,507
Solution 1
The compiler will optimize your code through inlining and removing calls to empty functions.
Solution 2
will this function be removed on build?
Not unless you use it only within other asserts. A typical example would be this:
assert(() {
test();
return true;
}());
If you only use it this way, then yes the function will be removed on build.
Author by
selharxets
Updated on December 07, 2022Comments
-
selharxets 11 months
Let say I have this code:
void test(){ assert(() { print("This is Test"); }); }
As per this question, dart will remove
assert
on production buildbut how about
test()
function which being called?will this function be removed on build?
or will this have any significant impact on performance if I call empty function multiple times?