aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2015-08-10 01:28:48 +0300
committerZyX <kp-pav@yandex.ru>2015-10-08 22:00:36 +0300
commitc9963872ef11f536e9728bf3e709ab39fe5056ec (patch)
tree6c8a661208b11612a6d4d0949c488371d0194109 /src
parent4371842bcc0e5384d29a25a495c66691dae0cec5 (diff)
downloadrneovim-c9963872ef11f536e9728bf3e709ab39fe5056ec.tar.gz
rneovim-c9963872ef11f536e9728bf3e709ab39fe5056ec.tar.bz2
rneovim-c9963872ef11f536e9728bf3e709ab39fe5056ec.zip
shada: Always use merging when reading jumps and changes
Diffstat (limited to 'src')
-rw-r--r--src/nvim/shada.c175
1 files changed, 75 insertions, 100 deletions
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 2a2fb07b89..7ec954080b 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -1360,68 +1360,54 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
break;
}
} else {
- if (force) {
- if (curwin->w_jumplistlen == JUMPLISTSIZE) {
- // Jump list items are ignored in this case.
- free_xfmark(fm);
- } else {
- memmove(&curwin->w_jumplist[1], &curwin->w_jumplist[0],
- sizeof(curwin->w_jumplist[0])
- * (size_t) curwin->w_jumplistlen);
- curwin->w_jumplistidx++;
- curwin->w_jumplistlen++;
- curwin->w_jumplist[0] = fm;
- }
- } else {
- const int jl_len = curwin->w_jumplistlen;
- int i;
- for (i = 0; i < jl_len; i++) {
- const xfmark_T jl_fm = curwin->w_jumplist[i];
- if (jl_fm.fmark.timestamp >= cur_entry.timestamp) {
- if (marks_equal(fm.fmark.mark, jl_fm.fmark.mark)
- && (buf == NULL
- ? (jl_fm.fname != NULL
- && STRCMP(fm.fname, jl_fm.fname) == 0)
- : fm.fmark.fnum == jl_fm.fmark.fnum)) {
- i = -1;
- }
- break;
- }
- }
- if (i != -1) {
- if (i < jl_len) {
- if (jl_len == JUMPLISTSIZE) {
- free_xfmark(curwin->w_jumplist[0]);
- memmove(&curwin->w_jumplist[0], &curwin->w_jumplist[1],
- sizeof(curwin->w_jumplist[0]) * (size_t) i);
- } else {
- memmove(&curwin->w_jumplist[i + 1], &curwin->w_jumplist[i],
- sizeof(curwin->w_jumplist[0])
- * (size_t) (jl_len - i));
- }
- } else if (i == jl_len) {
- if (jl_len == JUMPLISTSIZE) {
- i = -1;
- } else if (jl_len > 0) {
- memmove(&curwin->w_jumplist[1], &curwin->w_jumplist[0],
- sizeof(curwin->w_jumplist[0])
- * (size_t) jl_len);
- }
+ const int jl_len = curwin->w_jumplistlen;
+ int i;
+ for (i = 0; i < jl_len; i++) {
+ const xfmark_T jl_fm = curwin->w_jumplist[i];
+ if (jl_fm.fmark.timestamp >= cur_entry.timestamp) {
+ if (marks_equal(fm.fmark.mark, jl_fm.fmark.mark)
+ && (buf == NULL
+ ? (jl_fm.fname != NULL
+ && STRCMP(fm.fname, jl_fm.fname) == 0)
+ : fm.fmark.fnum == jl_fm.fmark.fnum)) {
+ i = -1;
}
+ break;
}
- if (i != -1) {
- curwin->w_jumplist[i] = fm;
- if (jl_len < JUMPLISTSIZE) {
- curwin->w_jumplistlen++;
+ }
+ if (i != -1) {
+ if (i < jl_len) {
+ if (jl_len == JUMPLISTSIZE) {
+ free_xfmark(curwin->w_jumplist[0]);
+ memmove(&curwin->w_jumplist[0], &curwin->w_jumplist[1],
+ sizeof(curwin->w_jumplist[0]) * (size_t) i);
+ } else {
+ memmove(&curwin->w_jumplist[i + 1], &curwin->w_jumplist[i],
+ sizeof(curwin->w_jumplist[0])
+ * (size_t) (jl_len - i));
}
- if (curwin->w_jumplistidx > i
- && curwin->w_jumplistidx + 1 < curwin->w_jumplistlen) {
- curwin->w_jumplistidx++;
+ } else if (i == jl_len) {
+ if (jl_len == JUMPLISTSIZE) {
+ i = -1;
+ } else if (jl_len > 0) {
+ memmove(&curwin->w_jumplist[1], &curwin->w_jumplist[0],
+ sizeof(curwin->w_jumplist[0])
+ * (size_t) jl_len);
}
- } else {
- shada_free_shada_entry(&cur_entry);
}
}
+ if (i != -1) {
+ curwin->w_jumplist[i] = fm;
+ if (jl_len < JUMPLISTSIZE) {
+ curwin->w_jumplistlen++;
+ }
+ if (curwin->w_jumplistidx > i
+ && curwin->w_jumplistidx + 1 < curwin->w_jumplistlen) {
+ curwin->w_jumplistidx++;
+ }
+ } else {
+ shada_free_shada_entry(&cur_entry);
+ }
}
// Do not free shada entry: its allocated memory was saved above.
break;
@@ -1488,55 +1474,44 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
} else {
int kh_ret;
(void) kh_put(bufset, &cl_bufs, (uintptr_t) buf, &kh_ret);
- if (force) {
- if (buf->b_changelistlen == JUMPLISTSIZE) {
- free_fmark(buf->b_changelist[0]);
- memmove(buf->b_changelist, buf->b_changelist + 1,
- sizeof(buf->b_changelist[0]) * (JUMPLISTSIZE - 1));
- } else {
- buf->b_changelistlen++;
- }
- buf->b_changelist[buf->b_changelistlen - 1] = fm;
- } else {
- const int cl_len = buf->b_changelistlen;
- int i;
- for (i = cl_len; i > 0; i--) {
- const fmark_T cl_fm = buf->b_changelist[i - 1];
- if (cl_fm.timestamp <= cur_entry.timestamp) {
- if (marks_equal(fm.mark, cl_fm.mark)) {
- i = -1;
- }
- break;
- }
- }
- if (i > 0) {
- if (cl_len == JUMPLISTSIZE) {
- free_fmark(buf->b_changelist[0]);
- memmove(&buf->b_changelist[0], &buf->b_changelist[1],
- sizeof(buf->b_changelist[0]) * (size_t) i);
- } else {
- memmove(&buf->b_changelist[i + 1], &buf->b_changelist[i],
- sizeof(buf->b_changelist[0])
- * (size_t) (cl_len - i));
- }
- } else if (i == 0) {
- if (cl_len == JUMPLISTSIZE) {
+ const int cl_len = buf->b_changelistlen;
+ int i;
+ for (i = cl_len; i > 0; i--) {
+ const fmark_T cl_fm = buf->b_changelist[i - 1];
+ if (cl_fm.timestamp <= cur_entry.timestamp) {
+ if (marks_equal(fm.mark, cl_fm.mark)) {
i = -1;
- } else if (cl_len > 0) {
- memmove(&buf->b_changelist[1], &buf->b_changelist[0],
- sizeof(buf->b_changelist[0])
- * (size_t) cl_len);
}
+ break;
}
- if (i != -1) {
- buf->b_changelist[i] = fm;
- if (cl_len < JUMPLISTSIZE) {
- buf->b_changelistlen++;
- }
+ }
+ if (i > 0) {
+ if (cl_len == JUMPLISTSIZE) {
+ free_fmark(buf->b_changelist[0]);
+ memmove(&buf->b_changelist[0], &buf->b_changelist[1],
+ sizeof(buf->b_changelist[0]) * (size_t) i);
} else {
- shada_free_shada_entry(&cur_entry);
- cur_entry.data.filemark.fname = NULL;
+ memmove(&buf->b_changelist[i + 1], &buf->b_changelist[i],
+ sizeof(buf->b_changelist[0])
+ * (size_t) (cl_len - i));
+ }
+ } else if (i == 0) {
+ if (cl_len == JUMPLISTSIZE) {
+ i = -1;
+ } else if (cl_len > 0) {
+ memmove(&buf->b_changelist[1], &buf->b_changelist[0],
+ sizeof(buf->b_changelist[0])
+ * (size_t) cl_len);
+ }
+ }
+ if (i != -1) {
+ buf->b_changelist[i] = fm;
+ if (cl_len < JUMPLISTSIZE) {
+ buf->b_changelistlen++;
}
+ } else {
+ shada_free_shada_entry(&cur_entry);
+ cur_entry.data.filemark.fname = NULL;
}
}
// Do not free shada entry: except for fname, its allocated memory (i.e.