From 2d7e1c32a87655b78cd23f2a3ad9a7a140493bd5 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 11 Nov 2019 22:04:21 -0800 Subject: [PATCH] extmark: rename ExtendedMark => Extmark --- src/nvim/api/buffer.c | 6 ++---- src/nvim/api/private/helpers.c | 12 ++++-------- src/nvim/mark_extended.c | 19 +++++++++---------- src/nvim/mark_extended.h | 14 +++++++------- src/nvim/mark_extended_defs.h | 8 ++++---- 5 files changed, 26 insertions(+), 33 deletions(-) diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 58011702ac..9ec96840d1 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -1027,9 +1027,7 @@ ArrayOf(Integer) nvim_buf_get_extmark_by_id(Buffer buffer, Integer ns_id, return rv; } - ExtendedMark *extmark = extmark_from_id(buf, - (uint64_t)ns_id, - (uint64_t)id); + Extmark *extmark = extmark_from_id(buf, (uint64_t)ns_id, (uint64_t)id); if (!extmark) { return rv; } @@ -1129,7 +1127,7 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, for (size_t i = 0; i < kv_size(marks); i++) { Array mark = ARRAY_DICT_INIT; - ExtendedMark *extmark = kv_A(marks, i); + Extmark *extmark = kv_A(marks, i); ADD(mark, INTEGER_OBJ((Integer)extmark->mark_id)); ADD(mark, INTEGER_OBJ(extmark->line->lnum-1)); ADD(mark, INTEGER_OBJ(extmark->col-1)); diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 6b69350429..fbfdb27827 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -1512,11 +1512,8 @@ ArrayOf(Dictionary) keymap_array(String mode, buf_T *buf) // If throw == true then an error will be raised if nothing // was found // Returns NULL if something went wrong -ExtendedMark *extmark_from_id_or_pos(Buffer buffer, - Integer namespace, - Object id, - Error *err, - bool throw) +Extmark *extmark_from_id_or_pos(Buffer buffer, Integer namespace, Object id, + Error *err, bool throw) { buf_T *buf = find_buffer_by_handle(buffer, err); @@ -1524,7 +1521,7 @@ ExtendedMark *extmark_from_id_or_pos(Buffer buffer, return NULL; } - ExtendedMark *extmark = NULL; + Extmark *extmark = NULL; if (id.type == kObjectTypeArray) { if (id.data.array.size != 2) { api_set_error(err, kErrorTypeValidation, @@ -1603,8 +1600,7 @@ bool set_extmark_index_from_obj(buf_T *buf, Integer namespace, return false; } - ExtendedMark *extmark = extmark_from_id(buf, (uint64_t)namespace, - (uint64_t)id); + Extmark *extmark = extmark_from_id(buf, (uint64_t)namespace, (uint64_t)id); if (extmark) { *lnum = extmark->line->lnum; *colnr = extmark->col; diff --git a/src/nvim/mark_extended.c b/src/nvim/mark_extended.c index 88348a8045..545478065e 100644 --- a/src/nvim/mark_extended.c +++ b/src/nvim/mark_extended.c @@ -53,7 +53,7 @@ int extmark_set(buf_T *buf, uint64_t ns, uint64_t id, linenr_T lnum, colnr_T col, ExtmarkOp op) { - ExtendedMark *extmark = extmark_from_id(buf, ns, id); + Extmark *extmark = extmark_from_id(buf, ns, id); if (!extmark) { extmark_create(buf, ns, id, lnum, col, op); return true; @@ -72,7 +72,7 @@ int extmark_set(buf_T *buf, uint64_t ns, uint64_t id, // Returns 0 on missing id int extmark_del(buf_T *buf, uint64_t ns, uint64_t id, ExtmarkOp op) { - ExtendedMark *extmark = extmark_from_id(buf, ns, id); + Extmark *extmark = extmark_from_id(buf, ns, id); if (!extmark) { return 0; } @@ -197,7 +197,7 @@ static void extmark_create(buf_T *buf, uint64_t ns, uint64_t id, // update the position of an extmark // to update while iterating pass the markitems itr -static void extmark_update(ExtendedMark *extmark, buf_T *buf, +static void extmark_update(Extmark *extmark, buf_T *buf, uint64_t ns, uint64_t id, linenr_T lnum, colnr_T col, ExtmarkOp op, kbitr_t(markitems) *mitr) @@ -234,7 +234,7 @@ static void extmark_update(ExtendedMark *extmark, buf_T *buf, } } -static int extmark_delete(ExtendedMark *extmark, +static int extmark_delete(Extmark *extmark, buf_T *buf, uint64_t ns, uint64_t id, @@ -261,7 +261,7 @@ static int extmark_delete(ExtendedMark *extmark, } // Lookup an extmark by id -ExtendedMark *extmark_from_id(buf_T *buf, uint64_t ns, uint64_t id) +Extmark *extmark_from_id(buf_T *buf, uint64_t ns, uint64_t id) { if (!buf->b_extmark_ns) { return NULL; @@ -285,8 +285,7 @@ ExtendedMark *extmark_from_id(buf_T *buf, uint64_t ns, uint64_t id) } // Lookup an extmark by position -ExtendedMark *extmark_from_pos(buf_T *buf, - uint64_t ns, linenr_T lnum, colnr_T col) +Extmark *extmark_from_pos(buf_T *buf, uint64_t ns, linenr_T lnum, colnr_T col) { if (!buf->b_extmark_ns) { return NULL; @@ -1045,7 +1044,7 @@ bool extmark_copy_and_place(buf_T *buf, // marks within the same extmarkline. Too keep it simple, first delete all // items from the extmarkline and put them back in the right order. FOR_ALL_EXTMARKLINES(buf, l_lnum, u_lnum, { - kvec_t(ExtendedMark) temp_space = KV_INITIAL_VALUE; + kvec_t(Extmark) temp_space = KV_INITIAL_VALUE; bool same_line = extmarkline == destline; FOR_ALL_EXTMARKS_IN_LINE(extmarkline->items, (extmarkline->lnum > l_lnum) ? 0 : l_col, @@ -1068,7 +1067,7 @@ bool extmark_copy_and_place(buf_T *buf, }) if (same_line) { for (size_t i = 0; i < kv_size(temp_space); i++) { - ExtendedMark mark = kv_A(temp_space, i); + Extmark mark = kv_A(temp_space, i); extmark_put(p_col, mark.mark_id, extmarkline, mark.ns_id); } kv_destroy(temp_space); @@ -1120,7 +1119,7 @@ void extmarkline_free(ExtMarkLine *extmarkline) void extmark_put(colnr_T col, uint64_t id, ExtMarkLine *extmarkline, uint64_t ns) { - ExtendedMark t; + Extmark t; t.col = col; t.mark_id = id; t.line = extmarkline; diff --git a/src/nvim/mark_extended.h b/src/nvim/mark_extended.h index b8b766b243..b81adfaaef 100644 --- a/src/nvim/mark_extended.h +++ b/src/nvim/mark_extended.h @@ -51,7 +51,7 @@ // see FOR_ALL_? for documentation #define FOR_ALL_EXTMARKS(buf, ns, l_lnum, l_col, u_lnum, u_col, code)\ kbitr_t(markitems) mitr;\ - ExtendedMark mt;\ + Extmark mt;\ mt.ns_id = ns;\ mt.mark_id = 0;\ mt.line = NULL;\ @@ -60,7 +60,7 @@ if (!kb_itr_get(markitems, &extmarkline->items, mt, &mitr)) { \ kb_itr_next(markitems, &extmarkline->items, &mitr);\ } \ - ExtendedMark *extmark;\ + Extmark *extmark;\ for (; \ kb_itr_valid(&mitr); \ kb_itr_next(markitems, &extmarkline->items, &mitr)) { \ @@ -77,7 +77,7 @@ // see FOR_ALL_? for documentation #define FOR_ALL_EXTMARKS_PREV(buf, ns, l_lnum, l_col, u_lnum, u_col, code)\ kbitr_t(markitems) mitr;\ - ExtendedMark mt;\ + Extmark mt;\ mt.mark_id = sizeof(uint64_t);\ mt.ns_id = ns;\ FOR_ALL_EXTMARKLINES_PREV(buf, l_lnum, u_lnum, { \ @@ -85,7 +85,7 @@ if (!kb_itr_get(markitems, &extmarkline->items, mt, &mitr)) { \ kb_itr_prev(markitems, &extmarkline->items, &mitr);\ } \ - ExtendedMark *extmark;\ + Extmark *extmark;\ for (; \ kb_itr_valid(&mitr); \ kb_itr_prev(markitems, &extmarkline->items, &mitr)) { \ @@ -101,7 +101,7 @@ #define FOR_ALL_EXTMARKS_IN_LINE(items, l_col, u_col, code)\ kbitr_t(markitems) mitr;\ - ExtendedMark mt;\ + Extmark mt;\ mt.ns_id = 0;\ mt.mark_id = 0;\ mt.line = NULL;\ @@ -110,7 +110,7 @@ if (!kb_itr_get(markitems, &items, mt, &mitr)) { \ kb_itr_next(markitems, &items, &mitr);\ } \ - ExtendedMark *extmark;\ + Extmark *extmark;\ for (; kb_itr_valid(&mitr); kb_itr_next(markitems, &items, &mitr)) { \ extmark = &kb_itr_key(&mitr);\ if (extmark->col > extmarkline_u_col) { \ @@ -126,7 +126,7 @@ typedef struct ExtmarkNs { // For namespacing extmarks } ExtmarkNs; -typedef kvec_t(ExtendedMark *) ExtmarkArray; +typedef kvec_t(Extmark *) ExtmarkArray; // Undo/redo extmarks diff --git a/src/nvim/mark_extended_defs.h b/src/nvim/mark_extended_defs.h index b9475d46f5..42d57229f0 100644 --- a/src/nvim/mark_extended_defs.h +++ b/src/nvim/mark_extended_defs.h @@ -8,19 +8,19 @@ struct ExtMarkLine; -typedef struct ExtendedMark +typedef struct Extmark { uint64_t ns_id; uint64_t mark_id; struct ExtMarkLine *line; colnr_T col; -} ExtendedMark; +} Extmark; // We only need to compare columns as rows are stored in a different tree. // Marks are ordered by: position, namespace, mark_id // This improves moving marks but slows down all other use cases (searches) -static inline int extmark_cmp(ExtendedMark a, ExtendedMark b) +static inline int extmark_cmp(Extmark a, Extmark b) { int cmp = kb_generic_cmp(a.col, b.col); if (cmp != 0) { @@ -35,7 +35,7 @@ static inline int extmark_cmp(ExtendedMark a, ExtendedMark b) #define markitems_cmp(a, b) (extmark_cmp((a), (b))) -KBTREE_INIT(markitems, ExtendedMark, markitems_cmp, 10) +KBTREE_INIT(markitems, Extmark, markitems_cmp, 10) typedef struct ExtMarkLine {