patch 8.2.4683: verbose check with dict_find() to see if a key is present
Problem: Verbose check with dict_find() to see if a key is present.
Solution: Add dict_has_key(). (Yegappan Lakshmanan, closes #10074)
diff --git a/src/match.c b/src/match.c
index 5041d6b..ce35bac 100644
--- a/src/match.c
+++ b/src/match.c
@@ -938,7 +938,7 @@
return FAIL;
}
- if (dict_find(tv->vval.v_dict, (char_u *)"conceal", -1) != NULL)
+ if (dict_has_key(tv->vval.v_dict, "conceal"))
*conceal_char = dict_get_string(tv->vval.v_dict,
(char_u *)"conceal", FALSE);
@@ -1088,11 +1088,11 @@
emsg(_(e_invalid_argument));
return;
}
- if (!(dict_find(d, (char_u *)"group", -1) != NULL
- && (dict_find(d, (char_u *)"pattern", -1) != NULL
- || dict_find(d, (char_u *)"pos1", -1) != NULL)
- && dict_find(d, (char_u *)"priority", -1) != NULL
- && dict_find(d, (char_u *)"id", -1) != NULL))
+ if (!(dict_has_key(d, "group")
+ && (dict_has_key(d, "pattern")
+ || dict_has_key(d, "pos1"))
+ && dict_has_key(d, "priority")
+ && dict_has_key(d, "id")))
{
emsg(_(e_invalid_argument));
return;
@@ -1113,7 +1113,7 @@
char_u *conceal;
d = li->li_tv.vval.v_dict;
- if (dict_find(d, (char_u *)"pattern", -1) == NULL)
+ if (!dict_has_key(d, "pattern"))
{
if (s == NULL)
{
@@ -1142,7 +1142,7 @@
group = dict_get_string(d, (char_u *)"group", TRUE);
priority = (int)dict_get_number(d, (char_u *)"priority");
id = (int)dict_get_number(d, (char_u *)"id");
- conceal = dict_find(d, (char_u *)"conceal", -1) != NULL
+ conceal = dict_has_key(d, "conceal")
? dict_get_string(d, (char_u *)"conceal", TRUE)
: NULL;
if (i == 0)