Create a constant unusedPartType object instead of recreating it each time

This commit is contained in:
Gilles Moris
2019-05-15 07:07:21 +02:00
parent faaaa2618f
commit 94b1490b7b
4 changed files with 7 additions and 3 deletions

View File

@@ -375,7 +375,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
partNum = newPartNum;
if ((partNum >= 0) && (partNum < (int) GetNumParts())) {
typeHelper = GetString(typeCode, 2);
if ((typeHelper != (GUIDData) "00000000-0000-0000-0000-000000000000") &&
if ((typeHelper != PartType::unusedPartType) &&
(ChangePartType(partNum, typeHelper))) {
saveData = 1;
} else {

View File

@@ -434,7 +434,7 @@ void GPTPart::ReversePartBytes(void) {
void GPTPart::ChangeType(void) {
string line;
int changeName;
PartType tempType = (GUIDData) "00000000-0000-0000-0000-000000000000";
PartType tempType = PartType::unusedPartType;
#ifdef USE_UTF16
changeName = (GetDescription() == GetUTypeName());
@@ -454,7 +454,7 @@ void GPTPart::ChangeType(void) {
else
tempType = line;
} // if/else
} while (tempType == (GUIDData) "00000000-0000-0000-0000-000000000000");
} while (tempType == PartType::unusedPartType);
partitionType = tempType;
cout << "Changed type of partition to '" << partitionType.TypeName() << "'\n";
if (changeName) {

View File

@@ -19,6 +19,7 @@ using namespace std;
int PartType::numInstances = 0;
AType* PartType::allTypes = NULL;
AType* PartType::lastType = NULL;
const PartType PartType::unusedPartType = (GUIDData) "00000000-0000-0000-0000-000000000000";
// Constructor. Its main task is to initialize the data list, but only
// if this is the first instance, since it's a static linked list.

View File

@@ -36,6 +36,9 @@ protected:
static AType* lastType; // Pointer to last entry in the list
void AddAllTypes(void);
public:
// PartType with GUID "00000000-0000-0000-0000-000000000000"
static const PartType unusedPartType;
PartType(void);
PartType(const PartType & orig);
PartType(const GUIDData & orig);