avoid unnecessary swap() call of vector<int> which will be dropped on
the floor after getting its first element, which can be retrieved using
another parameter using _pg_to_up_acting_osds() directly.
Signed-off-by: Kefu Chai <kchai@redhat.com>
// pg -> acting primary osd
int get_pg_acting_primary(pg_t pg) const {
- vector<int> group;
- int nrep = pg_to_acting_osds(pg, group);
- if (nrep > 0)
- return group[0];
- return -1; // we fail!
+ int primary = -1;
+ _pg_to_up_acting_osds(pg, nullptr, nullptr, nullptr, &primary);
+ return primary;
}
/*