From 34630c671e826ed871e5cf4beb37e79c343cd3c7 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Sat, 26 Sep 2020 00:36:58 +0200 Subject: [PATCH] Node: cache the label Computing the path spec again and again is apparently very very expensive. --- lib/core/graph.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/core/graph.dart b/lib/core/graph.dart index cf458648..10b3d492 100644 --- a/lib/core/graph.dart +++ b/lib/core/graph.dart @@ -17,9 +17,14 @@ class Node { double forceX = 0.0; double forceY = 0.0; + String _label; + Node(this.note); - String get label => note.pathSpec(); + String get label { + _label ??= note.pathSpec(); + return _label; + } @override String toString() => "Node{$label, $x, $y}";