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 -- [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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202011101955.0AAJt08S643021%40masaka.moolenaar.net.

Raspunde prin e-mail lui