summaryrefslogtreecommitdiff
path: root/src/desktop_vec.c
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2022-11-19 19:33:57 +0000
committerPhil Jones <philj56@gmail.com>2022-11-19 19:33:57 +0000
commit8ab1b98328d720dec70087f0435210cdd5c67852 (patch)
treec084a2faf2be548f67450dca5c4d6d92adfee4c1 /src/desktop_vec.c
parent5da0579864a13b11bf0808f7f69f7b22f18054b1 (diff)
Make vector finding functions names clearer.
This adds `_sorted` to the names of `string_vec_find` and `desktop_vec_find`, to make it clear that these functions require their input to already be sorted. Also fix a potential bug from not sorting the list of desktops in drun mode.
Diffstat (limited to 'src/desktop_vec.c')
-rw-r--r--src/desktop_vec.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/desktop_vec.c b/src/desktop_vec.c
index 102dd67..a9aa1f7 100644
--- a/src/desktop_vec.c
+++ b/src/desktop_vec.c
@@ -135,7 +135,7 @@ void desktop_vec_sort(struct desktop_vec *restrict vec)
qsort(vec->buf, vec->count, sizeof(vec->buf[0]), cmpdesktopp);
}
-struct desktop_entry *desktop_vec_find(struct desktop_vec *restrict vec, const char *name)
+struct desktop_entry *desktop_vec_find_sorted(struct desktop_vec *restrict vec, const char *name)
{
/*
* Explicitly cast away const-ness, as even though we won't modify the
@@ -256,8 +256,9 @@ bool match_current_desktop(char * const *desktop_list, gsize length)
}
free(tmp);
+ string_vec_sort(&desktops);
for (gsize i = 0; i < length; i++) {
- if (string_vec_find(&desktops, desktop_list[i])) {
+ if (string_vec_find_sorted(&desktops, desktop_list[i])) {
return true;
}
}
@@ -346,7 +347,7 @@ bool match_current_desktop(char * const *desktop_list, gsize length)
// tmp = xstrdup(desktop_list);
// desktop = strtok_r(tmp, ";", &saveptr);
// while (desktop != NULL) {
-// if (string_vec_find(&desktops, desktop)) {
+// if (string_vec_find_sorted(&desktops, desktop)) {
// return true;
// }
// desktop = strtok_r(NULL, ";", &saveptr);