diff options
| author | Randy Palamar <randy@rnpnr.xyz> | 2025-01-04 21:04:22 -0700 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2025-01-04 21:20:22 -0700 |
| commit | 1e52d33a3696016a7338d08c1c2bf6ef8f324e75 (patch) | |
| tree | 28f196c7795ecebd5dae9d37fcc40e0e4458c80d /sam.c | |
| parent | 6d362f260c1573d5fb1b60be4ea84689600d368e (diff) | |
| download | vis-1e52d33a3696016a7338d08c1c2bf6ef8f324e75.tar.gz vis-1e52d33a3696016a7338d08c1c2bf6ef8f324e75.tar.xz | |
remove duplicated read_buffer functions
When you take a pointer to a function in C that function is going
to appear in full in the final binary. This means that there were
3 sections of the final binary with the exact same code.
You could argue that in very high performance programs having that
function closer to the current instruction when it is needed will
give a performance boost but there are so many other places to
gain more significant speed ups in vis before that would be
remotely relevant.
In fact, removing these allows the buffer_append call to inlined
so that buffer_insert can be hopped to directly instead of
including a useless hop in the middle.
Diffstat (limited to 'sam.c')
| -rw-r--r-- | sam.c | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -1743,11 +1743,6 @@ static bool cmd_write(Vis *vis, Win *win, Command *cmd, const char *argv[], Sele return true; } -static ssize_t read_buffer(void *context, char *data, size_t len) { - buffer_append(context, data, len); - return len; -} - static bool cmd_filter(Vis *vis, Win *win, Command *cmd, const char *argv[], Selection *sel, Filerange *range) { if (!win) return false; @@ -1756,7 +1751,8 @@ static bool cmd_filter(Vis *vis, Win *win, Command *cmd, const char *argv[], Sel buffer_init(&bufout); buffer_init(&buferr); - int status = vis_pipe(vis, win->file, range, &argv[1], &bufout, read_buffer, &buferr, read_buffer, false); + int status = vis_pipe(vis, win->file, range, &argv[1], &bufout, read_into_buffer, &buferr, + read_into_buffer, false); if (vis->interrupted) { vis_info_show(vis, "Command cancelled"); @@ -1796,7 +1792,8 @@ static bool cmd_pipeout(Vis *vis, Win *win, Command *cmd, const char *argv[], Se Buffer buferr; buffer_init(&buferr); - int status = vis_pipe(vis, win->file, range, (const char*[]){ argv[1], NULL }, NULL, NULL, &buferr, read_buffer, false); + int status = vis_pipe(vis, win->file, range, (const char*[]){ argv[1], NULL }, NULL, NULL, + &buferr, read_into_buffer, false); if (vis->interrupted) vis_info_show(vis, "Command cancelled"); |
