mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 09:26:30 +00:00
shada: Refactor code that works with hms.last_hist_entry
This commit is contained in:
@@ -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.
|
/// @param[in] can_free_entry True if entry can be freed.
|
||||||
static void hms_insert(HistoryMergerState *const hms_p, const ShadaEntry entry,
|
static void hms_insert(HistoryMergerState *const hms_p, const ShadaEntry entry,
|
||||||
const bool do_iter, const bool can_free_entry)
|
const bool do_iter, const bool can_free_entry)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
if (do_iter) {
|
if (do_iter) {
|
||||||
|
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) {
|
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);
|
|
||||||
hms_p->last_hist_entry.type = kSDItemMissing;
|
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->iter = shada_hist_iter(hms_p->iter, hms_p->history_type,
|
||||||
hms_p->reading,
|
hms_p->reading, &hms_p->last_hist_entry);
|
||||||
&(hms_p->last_hist_entry));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HMLList *const hmll = &hms_p->hmll;
|
HMLList *const hmll = &hms_p->hmll;
|
||||||
@@ -1107,15 +1102,13 @@ static inline void hms_insert_whole_neovim_history(
|
|||||||
HistoryMergerState *const hms_p)
|
HistoryMergerState *const hms_p)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
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);
|
hms_insert(hms_p, hms_p->last_hist_entry, false, hms_p->reading);
|
||||||
|
if (hms_p->iter == NULL) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
while (hms_p->iter != NULL
|
|
||||||
&& hms_p->last_hist_entry.type != kSDItemMissing) {
|
|
||||||
hms_p->iter = shada_hist_iter(hms_p->iter, hms_p->history_type,
|
hms_p->iter = shada_hist_iter(hms_p->iter, hms_p->history_type,
|
||||||
hms_p->reading,
|
hms_p->reading, &hms_p->last_hist_entry);
|
||||||
&(hms_p->last_hist_entry));
|
|
||||||
hms_insert(hms_p, hms_p->last_hist_entry, false, hms_p->reading);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user