Don't duplicate work in `where`. (#58)
* Don't duplicate work in `where`.
Fixes #57
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 194b5cc..4aa15dc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.2.1
+
+* Fix `Characters.where` which unnecessarily did the iteration and test twice.
+
## 1.2.0
* Adds `Characters.empty` constant and makes `Characters("")` return it.
diff --git a/README.md b/README.md
index c0c12ad..34340db 100644
--- a/README.md
+++ b/README.md
@@ -123,7 +123,7 @@
[Characters]: https://pub.dev/documentation/characters/latest/characters/Characters-class.html "Characters class"
[Code Points]: https://unicode.org/glossary/#code_point "Unicode Code Point"
[Code Units]: https://unicode.org/glossary/#code_unit "Unicode Code Units"
-[Glyphs]: http://unicode.org/glossary/#glyph "Unicode Glyphs"
+[Glyphs]: https://unicode.org/glossary/#glyph "Unicode Glyphs"
[Grapheme Clusters]: https://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries "Unicode (Extended) Grapheme Cluster"
[Iterable]: https://api.dart.dev/stable/2.0.0/dart-core/Iterable-class.html "Iterable class"
[Runes]: https://api.dart.dev/stable/2.0.0/dart-core/Runes-class.html "Runes class"
diff --git a/lib/src/characters_impl.dart b/lib/src/characters_impl.dart
index a87aa68..ebd8434 100644
--- a/lib/src/characters_impl.dart
+++ b/lib/src/characters_impl.dart
@@ -303,7 +303,7 @@
Characters where(bool Function(String) test) {
var string = super.where(test).join();
if (string.isEmpty) return Characters.empty;
- return StringCharacters(super.where(test).join());
+ return StringCharacters(string);
}
@override
diff --git a/pubspec.yaml b/pubspec.yaml
index 065c191..90d1ca0 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: characters
-version: 1.2.0
+version: 1.2.1
description: String replacement with operations that are Unicode/grapheme cluster aware.
repository: https://www.github.com/dart-lang/characters