mirror of
https://github.com/Zygo/bees.git
synced 2025-05-18 05:45:45 +02:00
crucible: use set instead of vector in BtrfsExtentWalker
This gets rid of some more big memsets. It may replace them with a lot of tiny mallocs, though. If this turns out to be a bad idea then at least we can easily revert the change.
This commit is contained in:
parent
7782b79e4b
commit
e835e8766e
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -150,6 +151,7 @@ namespace crucible {
|
|||||||
BtrfsIoctlSearchHeader();
|
BtrfsIoctlSearchHeader();
|
||||||
vector<char> m_data;
|
vector<char> m_data;
|
||||||
size_t set_data(const vector<char> &v, size_t offset);
|
size_t set_data(const vector<char> &v, size_t offset);
|
||||||
|
bool operator<(const BtrfsIoctlSearchHeader &that) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
ostream & operator<<(ostream &os, const btrfs_ioctl_search_header &hdr);
|
ostream & operator<<(ostream &os, const btrfs_ioctl_search_header &hdr);
|
||||||
@ -164,7 +166,8 @@ namespace crucible {
|
|||||||
void next_min(const BtrfsIoctlSearchHeader& ref);
|
void next_min(const BtrfsIoctlSearchHeader& ref);
|
||||||
|
|
||||||
size_t m_buf_size;
|
size_t m_buf_size;
|
||||||
vector<BtrfsIoctlSearchHeader> m_result;
|
set<BtrfsIoctlSearchHeader> m_result;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ostream & operator<<(ostream &os, const btrfs_ioctl_search_key &key);
|
ostream & operator<<(ostream &os, const btrfs_ioctl_search_key &key);
|
||||||
|
@ -707,6 +707,12 @@ namespace crucible {
|
|||||||
return offset + len;
|
return offset + len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
BtrfsIoctlSearchHeader::operator<(const BtrfsIoctlSearchHeader &that) const
|
||||||
|
{
|
||||||
|
return tie(objectid, type, offset, len, transid) < tie(that.objectid, that.type, that.offset, that.len, that.transid);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BtrfsIoctlSearchKey::do_ioctl_nothrow(int fd)
|
BtrfsIoctlSearchKey::do_ioctl_nothrow(int fd)
|
||||||
{
|
{
|
||||||
@ -727,13 +733,12 @@ namespace crucible {
|
|||||||
static_cast<btrfs_ioctl_search_key&>(*this) = ioctl_ptr->key;
|
static_cast<btrfs_ioctl_search_key&>(*this) = ioctl_ptr->key;
|
||||||
|
|
||||||
m_result.clear();
|
m_result.clear();
|
||||||
m_result.reserve(nr_items);
|
|
||||||
|
|
||||||
size_t offset = pointer_distance(ioctl_ptr->buf, ioctl_ptr);
|
size_t offset = pointer_distance(ioctl_ptr->buf, ioctl_ptr);
|
||||||
for (decltype(nr_items) i = 0; i < nr_items; ++i) {
|
for (decltype(nr_items) i = 0; i < nr_items; ++i) {
|
||||||
BtrfsIoctlSearchHeader item;
|
BtrfsIoctlSearchHeader item;
|
||||||
offset = item.set_data(ioctl_arg, offset);
|
offset = item.set_data(ioctl_arg, offset);
|
||||||
m_result.push_back(item);
|
m_result.insert(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user