changeset 29653:aa83cf7bef1c v9.0.0167

patch 9.0.0167: checking for text properties could be a bit more efficient Commit: https://github.com/vim/vim/commit/38ea2733b4dd8e9bfc4a5bb5c11cb661bf000c4e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 7 22:04:56 2022 +0100 patch 9.0.0167: checking for text properties could be a bit more efficient Problem: Checking for text properties could be a bit more efficient. Solution: Return early when there are no text properties. Update TODO items.
author Bram Moolenaar <Bram@vim.org>
date Sun, 07 Aug 2022 23:15:03 +0200
parents 85fd541404a5
children bba83ec5cf86
files src/textprop.c src/version.c
diffstat 2 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -11,12 +11,8 @@
  * 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
     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));
 }
 
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    167,
+/**/
     166,
 /**/
     165,