Merge pull request #163 from Neptilo/master

Fix bug when line starts before a chunk and ends after it
This commit is contained in:
Syoyo Fujita
2018-02-09 20:10:16 +09:00
committed by GitHub

View File

@@ -1329,11 +1329,10 @@ bool parseObj(attrib_t *attrib, std::vector<shape_t> *shapes,
} }
} }
// Find extra line which spand across chunk boundary. // If at least one line started in this chunk, find where it ends in the rest of the buffer
if ((t < num_threads) && (buf[end_idx - 1] != '\n')) { if ((prev_pos != start_idx) && (t < num_threads) && (buf[end_idx - 1] != '\n')) {
auto extra_span_idx = (std::min)(end_idx - 1 + chunk_size, len); for (size_t i = end_idx; i < len; i++) {
for (size_t i = end_idx; i < extra_span_idx; i++) { if (is_line_ending(buf, i, len)) {
if (is_line_ending(buf, i, extra_span_idx)) {
LineInfo info; LineInfo info;
info.pos = prev_pos; info.pos = prev_pos;
info.len = i - prev_pos; info.len = i - prev_pos;