Skip to content

Commit f98b405

Browse files
committed
Switch to splay tree
1 parent da3a598 commit f98b405

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎packages/palette_generator/lib/palette_generator.dart‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// found in the LICENSE file.
44

55
import 'dart:async';
6+
import 'dart:collection';
67
import 'dart:math' as math;
78
import 'dart:typed_data';
89
import 'dart:ui' as ui;
@@ -1115,7 +1116,9 @@ class _ColorCutQuantizer {
11151116
await image.toByteData(format: ui.ImageByteFormat.rawRgba);
11161117
final Iterable<Color> pixels =
11171118
_getImagePixels(imageData, image.width, image.height, region: region);
1118-
final Map<Color, _ColorCount> hist = <Color, _ColorCount>{};
1119+
final Map<Color, _ColorCount> hist =
1120+
SplayTreeMap<Color, _ColorCount>((Color color1, Color color2) =>
1121+
color1.value.compareTo(color2.value));
11191122
Color currentColor;
11201123
_ColorCount currentColorCount;
11211124
for (Color pixel in pixels) {

0 commit comments

Comments
 (0)