Create a constant unusedPartType object instead of recreating it each time
This commit is contained in:
2
gptcl.cc
2
gptcl.cc
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user