Mercurial > vim
comparison src/dict.c @ 20128:0b35a7ffceb2 v8.2.0619
patch 8.2.0619: null dict is not handled like an empty dict
Commit: https://github.com/vim/vim/commit/ea04a6e8baff2f27da7cdd54bf70a5525994f76d
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 23 13:38:02 2020 +0200
patch 8.2.0619: null dict is not handled like an empty dict
Problem: Null dict is not handled like an empty dict.
Solution: Fix the code and add tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5968)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 23 Apr 2020 13:45:04 +0200 |
parents | fc3cdc819d80 |
children | 0e1dfff4f294 |
comparison
equal
deleted
inserted
replaced
20127:a62c4185482f | 20128:0b35a7ffceb2 |
---|---|
975 { | 975 { |
976 hashitem_T *hi; | 976 hashitem_T *hi; |
977 dictitem_T *item2; | 977 dictitem_T *item2; |
978 int todo; | 978 int todo; |
979 | 979 |
980 if (d1 == NULL && d2 == NULL) | |
981 return TRUE; | |
982 if (d1 == NULL || d2 == NULL) | |
983 return FALSE; | |
984 if (d1 == d2) | 980 if (d1 == d2) |
985 return TRUE; | 981 return TRUE; |
986 if (dict_len(d1) != dict_len(d2)) | 982 if (dict_len(d1) != dict_len(d2)) |
983 return FALSE; | |
984 if (dict_len(d1) == 0) | |
985 // empty and NULL dicts are considered equal | |
986 return TRUE; | |
987 if (d1 == NULL || d2 == NULL) | |
987 return FALSE; | 988 return FALSE; |
988 | 989 |
989 todo = (int)d1->dv_hashtab.ht_used; | 990 todo = (int)d1->dv_hashtab.ht_used; |
990 for (hi = d1->dv_hashtab.ht_array; todo > 0; ++hi) | 991 for (hi = d1->dv_hashtab.ht_array; todo > 0; ++hi) |
991 { | 992 { |