summaryrefslogtreecommitdiffstats
path: root/src/evalbuffer.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-11-21 19:57:04 +0000
committerBram Moolenaar <Bram@vim.org>2022-11-21 19:57:04 +0000
commitce30ccc06af7f2c03762e5b18dde37b26ea6ec42 (patch)
tree2933f7b9a71269829df045bf8b59178e698c937a /src/evalbuffer.c
parent29967732761d1ffb5592db5f5aa7036f5b52abf1 (diff)
patch 9.0.0916: getbufline() is inefficient for getting a single linev9.0.0916
Problem: getbufline() is inefficient for getting a single line. Solution: Add getbufoneline().
Diffstat (limited to 'src/evalbuffer.c')
-rw-r--r--src/evalbuffer.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/evalbuffer.c b/src/evalbuffer.c
index 4b514ddab4..52662a6533 100644
--- a/src/evalbuffer.c
+++ b/src/evalbuffer.c
@@ -814,10 +814,11 @@ get_buffer_lines(
}
/*
- * "getbufline()" function
+ * "retlist" TRUE: "getbufline()" function
+ * "retlist" FALSE: "getbufoneline()" function
*/
- void
-f_getbufline(typval_T *argvars, typval_T *rettv)
+ static void
+getbufline(typval_T *argvars, typval_T *rettv, int retlist)
{
linenr_T lnum = 1;
linenr_T end = 1;
@@ -842,7 +843,25 @@ f_getbufline(typval_T *argvars, typval_T *rettv)
end = tv_get_lnum_buf(&argvars[2], buf);
}
- get_buffer_lines(buf, lnum, end, TRUE, rettv);
+ get_buffer_lines(buf, lnum, end, retlist, rettv);
+}
+
+/*
+ * "getbufline()" function
+ */
+ void
+f_getbufline(typval_T *argvars, typval_T *rettv)
+{
+ getbufline(argvars, rettv, TRUE);
+}
+
+/*
+ * "getbufoneline()" function
+ */
+ void
+f_getbufoneline(typval_T *argvars, typval_T *rettv)
+{
+ getbufline(argvars, rettv, FALSE);
}
/*