Optimizing the check for multiple signs with icons on a line

23 views
Skip to first unread message

Yegappan Lakshmanan

unread,
Jun 25, 2019, 10:46:32 PM6/25/19
to vim_dev
Hi,

When multiple signs with icons are placed on the same line, then a
different icon is drawn in the sign column using the
netbeans_draw_multisign_indicator() function.
This function draws the icon only if a netbeans connection is
present (NETBEANS_OPEN).

The screen line refresh function (win_line) always checks whether
multiple signs are present on a line using the buf_signcount() function.
This function counts the number of signs with icons placed on a line.
This is done even though the netbeans connection is not present.
If the netbeans connection is not present, then there is no need to
count the number of signs as the multisign indicator will not be
displayed.

Does anyone see a problem if I change win_line() to call buf_signcount()
only if the netbeans connection is present?

Thanks,
Yegappan

Yegappan Lakshmanan

unread,
Jun 26, 2019, 12:05:16 AM6/26/19
to vim_dev
Hi,

Some code references are below.

On Tue, Jun 25, 2019 at 7:46 PM Yegappan Lakshmanan <yega...@gmail.com> wrote:
>
> Hi,
>
> When multiple signs with icons are placed on the same line, then a
> different icon is drawn in the sign column using the
> netbeans_draw_multisign_indicator() function.
> This function draws the icon only if a netbeans connection is
> present (NETBEANS_OPEN).
>

https://github.com/vim/vim/blob/master/src/netbeans.c#L3000

>
> The screen line refresh function (win_line) always checks whether
> multiple signs are present on a line using the buf_signcount() function.
>

https://github.com/vim/vim/blob/master/src/screen.c#L3105

>
> This function counts the number of signs with icons placed on a line.
>

https://github.com/vim/vim/blob/master/src/sign.c#L623

- Yegappan

Bram Moolenaar

unread,
Jun 27, 2019, 12:55:39 AM6/27/19
to vim...@googlegroups.com, Yegappan Lakshmanan
I haven't checked the default, but in general the behavior should not
change by only compiling with netbeans, it should actually be using
netbeans. Which isn't very often these days.

--
The software said it requires Windows 95 or better, so I installed Linux.

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///

Yegappan Lakshmanan

unread,
Jun 27, 2019, 9:36:18 AM6/27/19
to Bram Moolenaar, vim_dev
Hi Bram,

On Wed, Jun 26, 2019 at 9:55 PM Bram Moolenaar <Br...@moolenaar.net> wrote:
>
> Yegappan wrote:
>
> > When multiple signs with icons are placed on the same line, then a
> > different icon is drawn in the sign column using the
> > netbeans_draw_multisign_indicator() function.
> > This function draws the icon only if a netbeans connection is
> > present (NETBEANS_OPEN).
> >
> > The screen line refresh function (win_line) always checks whether
> > multiple signs are present on a line using the buf_signcount() function.
> > This function counts the number of signs with icons placed on a line.
> > This is done even though the netbeans connection is not present.
> > If the netbeans connection is not present, then there is no need to
> > count the number of signs as the multisign indicator will not be
> > displayed.
> >
> > Does anyone see a problem if I change win_line() to call buf_signcount()
> > only if the netbeans connection is present?
>
> I haven't checked the default, but in general the behavior should not
> change by only compiling with netbeans, it should actually be using
> netbeans. Which isn't very often these days.
>

With this change, the default behavior is not changing. The unnecessary
call to buf_signcount() is getting removed. The call to buf_signcount()
is expensive and is not necessary. When multiple signs are placed on
the same line, the attributes of the sign with the highest priority is
used. This includes the icon of that sign. So this is a safe change.

- Yegappan
Reply all
Reply to author
Forward
0 new messages