From 4bf9ea44cf89aa485790985b30f7ded8adaefc33 Mon Sep 17 00:00:00 2001
From: Patrick Spek
Date: Tue, 28 Aug 2018 16:27:28 +0200
Subject: Use .words for performance reasons
---
CHANGELOG.md | 5 +++++
lib/String/Fold.pm6 | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 618a64d..5b9a350 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,5 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic
Versioning](http://semver.org/spec/v2.0.0.html).
+## [UNRELEASED]
+### Changed
+- Now using `.words` instead of `.comb`, which improves performance by about
+ 10%.
+
## [0.1.0] - 2018-07-08
- Initial release
diff --git a/lib/String/Fold.pm6 b/lib/String/Fold.pm6
index 2db1155..9043b94 100644
--- a/lib/String/Fold.pm6
+++ b/lib/String/Fold.pm6
@@ -28,7 +28,7 @@ sub fold (
}
# Work through each word on the line and fold them to the maximum width.
- for $line.comb(/\S+/) -> $word {
+ for $line.words -> $word {
if (new-line-length(@current-words, $word, $indent) <= $width) {
@current-words.append($word);
next;
--
cgit v1.1