> > I still see a nested while loop. Is that readlly needed?
>
> I think so because a match list is orderd by a priority not an ID.
> However, if we really need to reduce a nested loop,
> a simple idea is something like this:
>
> cur = wp->w_match_head;
> while (cur != NULL && cur->id != wp->w_next_match_id)
> cur = cur->next;
> if (cur == NULL)
> id = wp->w_next_match_id;
> else
> id = wp->w_manual_match_id_max + 1000;
> wp->w_next_match_id = id + 1
>
> Once a overlap is found, intentionally assign max manual ID + 1000 as ID.
> The ID can be overlapped later though.
I tried to think it over again.
In the current mechanism, it is not possible to completely eliminate
an overlap between manual and automatic IDs.
Add 1000 here is to just reduce its possibility.
If that idea is acceptable, I would like to return back to my 1st proposal,
because it is more simple and no while loop is necessary.
Please let me know your concern.
if (id < -1 || id == 0)
{
EMSGN(_("E799: Invalid ID: %ld (must be greater than or equal to 1)"),
id);
return -1;
}
else if (id == -1)
{
id = wp->w_next_match_id;
wp->w_next_match_id++;
}
else
{
if (id < wp->w_next_match_id)
{
cur = wp->w_match_head;
while (cur != NULL)
{
if (cur->id == id)
{
EMSGN(_("E801: ID already taken: %ld"), id);
return -1;
}
cur = cur->next;
}
}
else
wp->w_next_match_id = id + 1000;
}
In this case, next_match_id is initialized to 4 in clear_matches() and
when the last match is deleted in match_delete().
--
--
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.