patch 9.0.0916: getbufline() is inefficient for getting a single line
Problem: getbufline() is inefficient for getting a single line.
Solution: Add getbufoneline().
diff --git a/src/evalbuffer.c b/src/evalbuffer.c
index 4b514dd..52662a6 100644
--- a/src/evalbuffer.c
+++ b/src/evalbuffer.c
@@ -814,10 +814,11 @@
}
/*
- * "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 @@
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);
}
/*