Rick Howe wrote:
> One of my plugins uses matchaddpos() to highlight some part of lines/columns
> in a file. If the file is big and it is used a lot of times,
> the plugin eventually becomes very slow.
>
> For example, in gvim 8.1 on my Windows 7, the following sample shows around
> 0.9sec, 4.8sec, 11.6sec, 20.7sec for 5,000, 10,000, 15,000, 20,000 times.
>
> for n in [5000, 10000, 15000, 20000]
> let t = reltime()
> for p in range(n)
> call matchaddpos('ToDo', [[1]])
> endfor
> echo printf('%5d : %s', n, reltimestr(reltime(t)))
> call clearmatches()
> endfor
>
> As far as I see in window.c, match_add() tries to search the match list
> and check if the next match ID has not been used, to find available match ID.
> However, if we can make the next match ID always available,
> no need to search and check the list.
This code clearly wasn't written with a long list of matches in mind.
> I would like to propose this change (window.c).
[...]
>
> With this change, it becomes 2 times faster by showing
> 0.5sec, 2.4sec, 5.9sec, 11.0sec for 5,000, 10,000, 15,000, 20,000 times.
>
> Please let me know if the change is reasonble or not.
One thing that won't work (even though it was not a good idea anyway):
If code would use manual IDs of 1000 and higher, assuming that matches
without a match ID would never reach 1000.
This breaks, because your proposal sets the next_match_id to one more
than the manual ID, thus they will very soon collide.
A solution would be to remember the range of manual IDs separately.
And next_match_id would try to avoid that range.
Also, we should reset next_match_id if the list becomes empty.
An alternative would be to use a dictionary to keep track of what IDs
are used. But updating the dictionary has overhead in itself.
--
hundred-and-one symptoms of being an internet addict:
239. You think "surfing" is something you do on dry land.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.