Patch 8.2.1973

5 views
Skip to first unread message

Bram Moolenaar

unread,
Nov 10, 2020, 2:55:14 PM11/10/20
to vim...@googlegroups.com

Patch 8.2.1973
Problem: Finding a patch number can be a bit slow.
Solution: Use binary search. (closes #7279)
Files: src/version.c


*** ../vim-8.2.1972/src/version.c 2020-11-10 18:23:47.870506514 +0100
--- src/version.c 2020-11-10 20:49:52.919846427 +0100
***************
*** 4725,4735 ****
int
has_patch(int n)
{
! int i;

! for (i = 0; included_patches[i] != 0; ++i)
! if (included_patches[i] == n)
return TRUE;
return FALSE;
}
#endif
--- 4727,4747 ----
int
has_patch(int n)
{
! int h, m, l;

! // Perform a binary search.
! l = 0;
! h = (int)(sizeof(included_patches) / sizeof(included_patches[0])) - 1;
! while (l < h)
! {
! m = (l + h) / 2;
! if (included_patches[m] == n)
return TRUE;
+ if (included_patches[m] < n)
+ h = m;
+ else
+ l = m + 1;
+ }
return FALSE;
}
#endif
***************
*** 4941,4949 ****
{
msg_puts(_("\nIncluded patches: "));
first = -1;
! // find last one
! for (i = 0; included_patches[i] != 0; ++i)
! ;
while (--i >= 0)
{
if (first < 0)
--- 4953,4959 ----
{
msg_puts(_("\nIncluded patches: "));
first = -1;
! i = (int)(sizeof(included_patches) / sizeof(included_patches[0])) - 1;
while (--i >= 0)
{
if (first < 0)
*** ../vim-8.2.1972/src/version.c 2020-11-10 18:23:47.870506514 +0100
--- src/version.c 2020-11-10 20:49:52.919846427 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1973,
/**/

--
Get a life? What is the URL where it can be downloaded?

/// 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 ///
Reply all
Reply to author
Forward
0 new messages