Skip to content

Commit feadb39

Browse files
committed
test 2
1 parent 6f42614 commit feadb39

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

mt-kahypar/io/io_utils.h

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include <fcntl.h>
3131
#include <string>
32+
#include <string_view>
3233
#include <thread>
3334
#include <sys/stat.h>
3435

@@ -196,23 +197,15 @@ void goto_next_line(char* mapped_file, size_t& pos, size_t& current_line, const
196197

197198
MT_KAHYPAR_ATTRIBUTE_ALWAYS_INLINE
198199
void goto_next_line_unrolled(char* mapped_file, size_t& pos, size_t& current_line, const size_t length) {
199-
for ( ; pos + LOOP_UNROLLING_VALUE <= length; pos += LOOP_UNROLLING_VALUE ) {
200-
bool found_end_of_line = false;
201-
size_t offset = 0;
202-
for (size_t i = 0; i < LOOP_UNROLLING_VALUE; ++i) {
203-
if (mapped_file[pos + i] == '\n') {
204-
found_end_of_line = true;
205-
offset = i;
206-
break;
207-
}
208-
}
200+
std::string_view sv(mapped_file + pos, length - pos);
201+
size_t offset = sv.find('\n');
209202

210-
if (found_end_of_line) {
211-
ASSERT(is_line_ending(mapped_file, pos + offset));
212-
pos += (offset + 1);
213-
++current_line;
214-
break;
215-
}
203+
if (offset != std::string_view::npos) {
204+
ASSERT(is_line_ending(mapped_file, pos + offset));
205+
pos += (offset + 1);
206+
++current_line;
207+
} else {
208+
pos = length;
216209
}
217210
}
218211

0 commit comments

Comments
 (0)