]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0167: checking for text properties could be a bit more efficient v9.0.0167
authorBram Moolenaar <Bram@vim.org>
Sun, 7 Aug 2022 21:04:56 +0000 (22:04 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 7 Aug 2022 21:04:56 +0000 (22:04 +0100)
Problem:    Checking for text properties could be a bit more efficient.
Solution:   Return early when there are no text properties.  Update TODO
            items.

src/textprop.c
src/version.c

index 679535375ca38c86364959e31455989fb04cba6c..d67ec4c7e8b6ecc196616fda7c019cdc56d33107 100644 (file)
  * Text properties implementation.  See ":help text-properties".
  *
  * TODO:
- * - Checking the text length to detect text properties is slow.  Use a flag in
- *   the index, like DB_MARKED?
  * - Also test line2byte() with many lines, so that ml_updatechunk() is taken
  *   into account.
- * - Perhaps have a window-local option to disable highlighting from text
- *   properties?
  */
 
 #include "vim.h"
@@ -579,13 +575,14 @@ get_text_props(buf_T *buf, linenr_T lnum, char_u **props, int will_change)
     text = ml_get_buf(buf, lnum, will_change);
     textlen = STRLEN(text) + 1;
     proplen = buf->b_ml.ml_line_len - textlen;
+    if (proplen == 0)
+       return 0;
     if (proplen % sizeof(textprop_T) != 0)
     {
        iemsg(_(e_text_property_info_corrupted));
        return 0;
     }
-    if (proplen > 0)
-       *props = text + textlen;
+    *props = text + textlen;
     return (int)(proplen / sizeof(textprop_T));
 }
 
index 7544d6f1a91c43c8d40a7ba733b0a4ca54c5153e..4bab4a58dc02773007080f98c963ede1dd3c8185 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    167,
 /**/
     166,
 /**/