From 19829794e6454f78334c9a67b74d8abb9bc66b25 Mon Sep 17 00:00:00 2001 From: Alberto Carretero Date: Wed, 11 Dec 2024 20:33:44 +0100 Subject: [PATCH] docs --- internal/strdist/strdist.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/strdist/strdist.go b/internal/strdist/strdist.go index 7fd2d460..d5b640ef 100644 --- a/internal/strdist/strdist.go +++ b/internal/strdist/strdist.go @@ -135,6 +135,9 @@ func globCost(ar, br rune) Cost { return Cost{SwapAB: 1, DeleteA: 1, InsertB: 1} } +// wildcardPrefixMatch compares whether the prefixes of a and b are equal up +// to the shortest one. The prefix is defined as the longest substring that +// starts at index 0 and does not contain a wildcard. func wildcardPrefixMatch(a, b string) bool { ai := strings.IndexAny(a, "*?") bi := strings.IndexAny(b, "*?") @@ -148,6 +151,9 @@ func wildcardPrefixMatch(a, b string) bool { return a[:mini] == b[:mini] } +// wildcardSuffixMatch compares whether the suffixes of a and b are equal up +// to the shortest one. The suffix is defined as the longest substring that ends +// at the string length and does not contain a wildcard. func wildcardSuffixMatch(a, b string) bool { ai := strings.LastIndexAny(a, "*?") la := 0