diff --git a/src/archive/ArchiveAscii.cc b/src/archive/ArchiveAscii.cc index 4a093f6a..2fd046f9 100644 --- a/src/archive/ArchiveAscii.cc +++ b/src/archive/ArchiveAscii.cc @@ -71,14 +71,19 @@ namespace zenkit { auto line = read->read_line(true); // Compatibility fix for binary data in ASCII archives. - // TODO: Optimize using `find_if`! - while (std::isspace(static_cast(line[0]))) { - line = line.substr(1); + std::string_view view = line; + size_t spaces_count = 0; + for (; spaces_count < view.size() + && std::isspace(static_cast(view[spaces_count])); + ++spaces_count); + + if (spaces_count > 0) { + view.remove_prefix(spaces_count); } - if (line != "[]") { - read->seek(static_cast(mark), Whence::BEG); - return false; + if (view != "[]") { + read->seek(static_cast(mark), Whence::BEG); + return false; } return true;