mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-02 01:57:30 +08:00
Reduce write() calls for explicitly separated buffers
This can improve performance for `string split ""` for up to 1.8x.
This commit is contained in:
parent
5d5709b859
commit
5ada59996f
|
@ -316,9 +316,13 @@ void output_stream_t::append_narrow_buffer(const separated_buffer_t &buffer) {
|
||||||
|
|
||||||
void output_stream_t::append_with_separation(const wchar_t *s, size_t len, separation_type_t type,
|
void output_stream_t::append_with_separation(const wchar_t *s, size_t len, separation_type_t type,
|
||||||
bool want_newline) {
|
bool want_newline) {
|
||||||
append(s, len);
|
|
||||||
if (type == separation_type_t::explicitly && want_newline) {
|
if (type == separation_type_t::explicitly && want_newline) {
|
||||||
append(L'\n');
|
// Try calling "append" less - it might write() to an fd
|
||||||
|
wcstring buf{s, len};
|
||||||
|
buf.push_back(L'\n');
|
||||||
|
append(buf);
|
||||||
|
} else {
|
||||||
|
append(s, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user