Personally, I haven't measured a significant difference between prop_add() and
prop_add_list() for normal text-properties. For signs, on the other hand,
there's a significant difference between sign_place() in a for-loop and
sign_place_list().
But what I've noticed is that calling prop_remove() can be very slow when
removing over a thousand virtual text-properties.
For comparison: with normal text-properties, we can group them under a given
text-prop ID and use that ID in prop_remove() to remove a set of "related"
text-properties:
prop_remove({
'id': group_id,
'bufnr': some_bufnr,
'type': 'my_prop_type',
'both': true,
'all': true
})
This is very efficient, even when removing 10'000 text-properties with the same
ID.
However, with virtual text-properties we cannot group them under the same ID
(why?), instead each virtual text will be assigned a unique ID. Thus, we need
to cache every ID returned by prop_add() and then remove them individually in a
for-loop, something like:
var virt_IDs: list<number>
# fill virt_IDs with IDs returned by prop_add() …
for i in virt_IDs
prop_remove({
'id': i,
'bufnr': some_bufnr
})
endfor
Since the IDs are unique within a buffer, we don't have to specify `type` or
`both` in `prop_remove()`. Nevertheless, removing virtual text this way is very
slow when several hundred properties need to be removed.
To give you an example, on my 10 year old laptop calling prop_remove() in a
for-loop to remove 10'000 text-properties takes over 2 seconds. If I remove the
'id' entry in prop_remove() and match by 'type' it takes only a few
milliseconds. It's also significantly faster when I add 'lnum' to prop_remove(),
but the problem is that lnum isn't known when removing the virtual-text since
the lines might have shifted.
I think removing a set of virtual text-properties is very common, for example,
when `align`, `wrap` or `text_padding_left` need to be toggled. The only way to
accomplish this is by removing the old ones and re-adding them with a different
'align', 'wrap' etc. value.