mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-23 08:12:08 +00:00
sstables: replace potentially large for loop with do_until
We are pushing ints here, so it shouldn't be that bad in practice. But a potentially gigantic for loop is just asking for a stall since we won't need_preempt() it. Signed-off-by: Glauber Costa <glauber@scylladb.com>
This commit is contained in:
@@ -646,22 +646,23 @@ future<> parse(random_access_reader& in, summary& s) {
|
||||
check_buf_size(buf, len);
|
||||
|
||||
s.entries.resize(s.header.size);
|
||||
|
||||
// Positions are encoded in little-endian.
|
||||
auto b = buf.get();
|
||||
s.positions = utils::chunked_vector<pos_type>();
|
||||
for (size_t i = 0; i < s.header.size; ++i) {
|
||||
return do_until([&s] { return s.positions.size() == s.header.size; }, [&s, b] () mutable {
|
||||
s.positions.push_back(seastar::read_le<pos_type>(b));
|
||||
b += sizeof(pos_type);
|
||||
}
|
||||
|
||||
// Since the keys in the index are not sized, we need to calculate
|
||||
// the start position of the index i+1 to determine the boundaries
|
||||
// of index i. The "memory_size" field in the header determines the
|
||||
// total memory used by the map, so if we push it to the vector, we
|
||||
// can guarantee that no conditionals are used, and we can always
|
||||
// query the position of the "next" index.
|
||||
s.positions.push_back(s.header.memory_size);
|
||||
return make_ready_future<>();
|
||||
}).then([&s] {
|
||||
// Since the keys in the index are not sized, we need to calculate
|
||||
// the start position of the index i+1 to determine the boundaries
|
||||
// of index i. The "memory_size" field in the header determines the
|
||||
// total memory used by the map, so if we push it to the vector, we
|
||||
// can guarantee that no conditionals are used, and we can always
|
||||
// query the position of the "next" index.
|
||||
s.positions.push_back(s.header.memory_size);
|
||||
return make_ready_future<>();
|
||||
});
|
||||
}).then([&in, &s] {
|
||||
in.seek(sizeof(summary::header) + s.header.memory_size);
|
||||
return parse(in, s.first_key, s.last_key);
|
||||
|
||||
Reference in New Issue
Block a user