From 1313d221eea1a55b3b4a56392e74ca41caabc434 Mon Sep 17 00:00:00 2001 From: cetio Date: Sun, 25 Aug 2024 18:27:41 -0400 Subject: [PATCH] idr --- source/tern/algorithm/mutation.d | 7 ++++--- source/tern/algorithm/searching.d | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/tern/algorithm/mutation.d b/source/tern/algorithm/mutation.d index 2aaee80..597b201 100644 --- a/source/tern/algorithm/mutation.d +++ b/source/tern/algorithm/mutation.d @@ -92,7 +92,6 @@ LazySubstitute!(A, B, C) substitute(A, B, C)(A range, B from, C to) A replace(A, B, C)(A range, B from, C to) if (isIndexable!A && isElement!(A, B) && isElement!(A, C)) { - Range!A ret = range; ret.plane!((ref i) { ret[i] = from; })(from); @@ -224,6 +223,8 @@ A[] split(A, B)(A range, B by) l = i + by.loadLength; })(by); + if (l < range.loadLength) + ret ~= range[l..$]; return ret; } @@ -247,8 +248,8 @@ A[] split(alias F, A)(A range) l = i + by.loadLength; }, F); - if (range.length > 0) - ret ~= range[0..$]; + if (l < range.loadLength) + ret ~= range[l..$]; return ret; } diff --git a/source/tern/algorithm/searching.d b/source/tern/algorithm/searching.d index 61bd8c6..2dda245 100644 --- a/source/tern/algorithm/searching.d +++ b/source/tern/algorithm/searching.d @@ -5,6 +5,7 @@ module tern.algorithm.searching; import tern.traits; import tern.typecons; import tern.functional; +import tern.algorithm; import tern.object : loadLength; import tern.memory : memchr, reference;