aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/marktree.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-10-13 21:09:49 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2021-10-23 11:11:00 +0200
commit8ade2f5b0495ee41868e52d48816d02249e2364d (patch)
treef308f3f937979a539e0bc8e79a6c891a87f495fd /src/nvim/marktree.c
parentd0f10a7addc17149d7e63ff20705762c357eb469 (diff)
downloadrneovim-8ade2f5b0495ee41868e52d48816d02249e2364d.tar.gz
rneovim-8ade2f5b0495ee41868e52d48816d02249e2364d.tar.bz2
rneovim-8ade2f5b0495ee41868e52d48816d02249e2364d.zip
refactor(decorations): mark decorations directly on the marktree
This allows to more quickly skip though regions which has non-decorative marks when redrawing. This might seem like a gratuitous micro-optimization in isolation. But! Soon decorations are gonna crop into other hot inner-loop paths, including the plines.c code for calculating the horizontal and vertical space of text. Then we want to quickly skip over regions with "only" overlaying decorations (which do not affect text size)
Diffstat (limited to 'src/nvim/marktree.c')
-rw-r--r--src/nvim/marktree.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c
index 39c1e36147..a7f540c748 100644
--- a/src/nvim/marktree.c
+++ b/src/nvim/marktree.c
@@ -221,9 +221,11 @@ static inline void marktree_putp_aux(MarkTree *b, mtnode_t *x, mtkey_t k)
}
}
-uint64_t marktree_put(MarkTree *b, int row, int col, bool right_gravity)
+uint64_t marktree_put(MarkTree *b, int row, int col, bool right_gravity, uint8_t decor_level)
{
uint64_t id = (b->next_id+=ID_INCR);
+ assert(decor_level < DECOR_LEVELS);
+ id = id | ((uint64_t)decor_level << DECOR_OFFSET);
uint64_t keyid = id;
if (right_gravity) {
// order all right gravity keys after the left ones, for effortless
@@ -235,9 +237,11 @@ uint64_t marktree_put(MarkTree *b, int row, int col, bool right_gravity)
}
uint64_t marktree_put_pair(MarkTree *b, int start_row, int start_col, bool start_right, int end_row,
- int end_col, bool end_right)
+ int end_col, bool end_right, uint8_t decor_level)
{
uint64_t id = (b->next_id+=ID_INCR)|PAIRED;
+ assert(decor_level < DECOR_LEVELS);
+ id = id | ((uint64_t)decor_level << DECOR_OFFSET);
uint64_t start_id = id|(start_right?RIGHT_GRAVITY:0);
uint64_t end_id = id|END_FLAG|(end_right?RIGHT_GRAVITY:0);
marktree_put_key(b, start_row, start_col, start_id);