commit 4cadd7de2ed0eaa41c7e1d1dfc61a63662af577a
parent d8afd96c4cec4c8288258f17c62586d57945d29a
Author: Sebastian <sebastian@sebsite.pw>
Date: Tue, 23 Jan 2024 15:58:44 -0500
hare::module: add rationale for linear search
insert_uniq is only used by seentags_compat. Slices of tags are small
enough that using a linear search is inconsequential, so the XXX comment
is replaced with a comment justifying the use of linear search.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hare/module/util.ha b/hare/module/util.ha
@@ -10,7 +10,8 @@ use time;
// insert a string into a sorted list of strings, deduplicated.
fn insert_uniq(into: *[]str, s: str) void = {
let i = 0z;
- // XXX: could use binary search
+ // the `into` slice is generally small enough that a linear search is
+ // fine
for (i < len(into) && strings::compare(into[i], s) < 0) {
i += 1;
};