cut: -w: avoid per character function calls

Adding a couple of inlining hints to the compiler
gives a 30% boost in raw character processing performance
in cut_fields_mb_any().

  $ yes $(yes eeeaae | head -n10K | paste -s -d,) | head -n10K > ll.in

  $ time LC_ALL=C.UTF-8 src/cut-before -f1 -w ll.in >/dev/null
  real	0m2.279s

  $ time LC_ALL=C.UTF-8 src/cut-after -f1 -w ll.in >/dev/null
  real	0m1.619s

* src/cut.c (scan_mb_blank_field): Tag as inline.
(scan_mb_delim_field): Likewise.
This commit is contained in:
Pádraig Brady committed 2026-09-04 21:10:45 +01:00
1 parent 1ee46ac2c9
commit f665fdffca
1 file changed
+2 -2
+2 -2
View File
@@ -497,7 +497,7 @@ append_field_1_bytes (mbbuf_t *mbbuf, mcel_t g, idx_t *n_bytes)
append_field_1_chunk (mbbuf_char_offset (mbbuf, g), g.len, n_bytes);
}
static enum field_terminator
static inline enum field_terminator
scan_mb_blank_field (mbbuf_t *mbbuf, struct mbfield_parser *parser,
bool *have_pending_line, bool write_field,
idx_t *n_bytes)
@@ -534,7 +534,7 @@ scan_mb_blank_field (mbbuf_t *mbbuf, struct mbfield_parser *parser,
}
}
static enum field_terminator
static inline enum field_terminator
scan_mb_delim_field (mbbuf_t *mbbuf, bool *have_pending_line,
bool write_field, idx_t *n_bytes)
{