This function is to improve performance. It copies CSV delimiter and eol without calling `memcpy`. Each CSV field is followed by a delimiter or eol, which is often only one or two chars. If copying both the field and delimiter with `memcpy`, CPU may suffer from high branch misprediction as we are tripping `memcpy` with interleaved (normal/tiny/normal/tiny/...) buffer sizes, which are handled separ
| 68 | // separately inside `memcpy`. This function goes fast path if the buffer |
| 69 | // size is one or two chars to leave `memcpy` only for copying CSV fields. |
| 70 | void CopyEndChars(char* dest, const char* src, size_t size) { |
| 71 | if (size == 1) { |
| 72 | // for fixed size memcpy, compiler will generate direct load/store opcode |
| 73 | memcpy(dest, src, 1); |
| 74 | } else if (size == 2) { |
| 75 | memcpy(dest, src, 2); |
| 76 | } else { |
| 77 | memcpy(dest, src, size); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | struct SliceIteratorFunctor { |
| 82 | Result<std::shared_ptr<RecordBatch>> Next() { |
no outgoing calls
no test coverage detected