diff options
author | ZyX <kp-pav@yandex.ru> | 2015-08-19 18:24:42 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2015-10-08 22:00:49 +0300 |
commit | 313b947e3fe1f290d91e0b48517145e103d178d2 (patch) | |
tree | 2773011484cea2d5570c126bf2258a55412848bc /src | |
parent | 48ba2f0109ad2b5bc51b08c55848d526b37fd8d0 (diff) | |
download | rneovim-313b947e3fe1f290d91e0b48517145e103d178d2.tar.gz rneovim-313b947e3fe1f290d91e0b48517145e103d178d2.tar.bz2 rneovim-313b947e3fe1f290d91e0b48517145e103d178d2.zip |
shada: Refactor code that works with hms.last_hist_entry
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/shada.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 3f8dfe827d..b3559f3451 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -1027,23 +1027,18 @@ static const void *shada_hist_iter(const void *const iter, /// @param[in] can_free_entry True if entry can be freed. static void hms_insert(HistoryMergerState *const hms_p, const ShadaEntry entry, const bool do_iter, const bool can_free_entry) + FUNC_ATTR_NONNULL_ALL { if (do_iter) { - if (hms_p->iter == NULL) { - if (hms_p->last_hist_entry.type != kSDItemMissing - && hms_p->last_hist_entry.timestamp < entry.timestamp) { - hms_insert(hms_p, hms_p->last_hist_entry, false, hms_p->reading); + while (hms_p->last_hist_entry.type != kSDItemMissing + && hms_p->last_hist_entry.timestamp < entry.timestamp) { + hms_insert(hms_p, hms_p->last_hist_entry, false, hms_p->reading); + if (hms_p->iter == NULL) { hms_p->last_hist_entry.type = kSDItemMissing; + break; } - } else { - while (hms_p->iter != NULL - && hms_p->last_hist_entry.type != kSDItemMissing - && hms_p->last_hist_entry.timestamp < entry.timestamp) { - hms_insert(hms_p, hms_p->last_hist_entry, false, hms_p->reading); - hms_p->iter = shada_hist_iter(hms_p->iter, hms_p->history_type, - hms_p->reading, - &(hms_p->last_hist_entry)); - } + hms_p->iter = shada_hist_iter(hms_p->iter, hms_p->history_type, + hms_p->reading, &hms_p->last_hist_entry); } } HMLList *const hmll = &hms_p->hmll; @@ -1107,15 +1102,13 @@ static inline void hms_insert_whole_neovim_history( HistoryMergerState *const hms_p) FUNC_ATTR_NONNULL_ALL { - if (hms_p->last_hist_entry.type != kSDItemMissing) { + while (hms_p->last_hist_entry.type != kSDItemMissing) { hms_insert(hms_p, hms_p->last_hist_entry, false, hms_p->reading); - } - while (hms_p->iter != NULL - && hms_p->last_hist_entry.type != kSDItemMissing) { + if (hms_p->iter == NULL) { + break; + } hms_p->iter = shada_hist_iter(hms_p->iter, hms_p->history_type, - hms_p->reading, - &(hms_p->last_hist_entry)); - hms_insert(hms_p, hms_p->last_hist_entry, false, hms_p->reading); + hms_p->reading, &hms_p->last_hist_entry); } } |