From ab0f40debd54038a04d1e32e2626831ca40abf2a Mon Sep 17 00:00:00 2001 From: Renato Athaydes Date: Fri, 15 Dec 2023 21:01:32 +0100 Subject: [PATCH] Use const constructor in 1.dart This speeds up the Dart solution by about 20% and it's now faster than all Java solutions. --- bench/algorithm/binarytrees/1.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bench/algorithm/binarytrees/1.dart b/bench/algorithm/binarytrees/1.dart index 2634f3c3..0dbbf34e 100644 --- a/bench/algorithm/binarytrees/1.dart +++ b/bench/algorithm/binarytrees/1.dart @@ -3,11 +3,11 @@ const int minDepth = 4; class Node { final Node? left; final Node? right; - Node._(this.left, this.right); + const Node._(this.left, this.right); factory Node.create(int depth) => depth > 0 ? Node._(Node.create(depth - 1), Node.create(depth - 1)) - : Node._(null, null); + : const Node._(null, null); int check() { var r = 1;