pmt: Improve performance and functions
- Added two new functions - Improved functions - Reformatted code (scripts and src/ include/) - Increased processing speed with multi-threading
This commit is contained in:
@@ -42,7 +42,7 @@ struct _entry {
|
||||
* The main type of the library. The Builder class is designed
|
||||
* to be easily manipulated and modified only on this class.
|
||||
*/
|
||||
class basic_partition_map {
|
||||
class basic_partition_map final {
|
||||
private:
|
||||
void _resize_map();
|
||||
[[nodiscard]] int _index_of(std::string_view name) const;
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
|
||||
using Map_t = basic_partition_map;
|
||||
|
||||
class basic_partition_map_builder {
|
||||
class basic_partition_map_builder final {
|
||||
private:
|
||||
Map_t _current_map;
|
||||
std::string _workdir;
|
||||
|
||||
@@ -81,7 +81,7 @@ std::string basic_partition_map_builder::getRealPathOf(const std::string_view na
|
||||
{
|
||||
_map_build_check();
|
||||
|
||||
std::string full = _workdir + "/" + name.data();
|
||||
const std::string full = (isLogical(name)) ? std::string("/dev/block/mapper/") + name.data() : _workdir + "/" + name.data();
|
||||
if (!_current_map.find(name)
|
||||
|| !std::filesystem::is_symlink(full))
|
||||
return {};
|
||||
|
||||
@@ -156,24 +156,21 @@ void basic_partition_map::merge(const basic_partition_map& map)
|
||||
|
||||
uint64_t basic_partition_map::get_size(const std::string_view name) const
|
||||
{
|
||||
int pos = _index_of(name);
|
||||
if (name == _data[pos].name) return _data[pos].props.size;
|
||||
if (const int pos = _index_of(name); name == _data[pos].name) return _data[pos].props.size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool basic_partition_map::is_logical(const std::string_view name) const
|
||||
{
|
||||
int pos = _index_of(name);
|
||||
if (name == _data[pos].name) return _data[pos].props.isLogical;
|
||||
if (const int pos = _index_of(name); name == _data[pos].name) return _data[pos].props.isLogical;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
basic_partition_map::_returnable_entry basic_partition_map::get_all(const std::string_view name) const
|
||||
{
|
||||
int pos = _index_of(name);
|
||||
if (name == _data[pos].name)
|
||||
if (const int pos = _index_of(name); name == _data[pos].name)
|
||||
return _returnable_entry{_data[pos].props.size, _data[pos].props.isLogical};
|
||||
|
||||
return _returnable_entry{};
|
||||
|
||||
Reference in New Issue
Block a user