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;
|
partNum = newPartNum;
|
||||||
if ((partNum >= 0) && (partNum < (int) GetNumParts())) {
|
if ((partNum >= 0) && (partNum < (int) GetNumParts())) {
|
||||||
typeHelper = GetString(typeCode, 2);
|
typeHelper = GetString(typeCode, 2);
|
||||||
if ((typeHelper != (GUIDData) "00000000-0000-0000-0000-000000000000") &&
|
if ((typeHelper != PartType::unusedPartType) &&
|
||||||
(ChangePartType(partNum, typeHelper))) {
|
(ChangePartType(partNum, typeHelper))) {
|
||||||
saveData = 1;
|
saveData = 1;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ void GPTPart::ReversePartBytes(void) {
|
|||||||
void GPTPart::ChangeType(void) {
|
void GPTPart::ChangeType(void) {
|
||||||
string line;
|
string line;
|
||||||
int changeName;
|
int changeName;
|
||||||
PartType tempType = (GUIDData) "00000000-0000-0000-0000-000000000000";
|
PartType tempType = PartType::unusedPartType;
|
||||||
|
|
||||||
#ifdef USE_UTF16
|
#ifdef USE_UTF16
|
||||||
changeName = (GetDescription() == GetUTypeName());
|
changeName = (GetDescription() == GetUTypeName());
|
||||||
@@ -454,7 +454,7 @@ void GPTPart::ChangeType(void) {
|
|||||||
else
|
else
|
||||||
tempType = line;
|
tempType = line;
|
||||||
} // if/else
|
} // if/else
|
||||||
} while (tempType == (GUIDData) "00000000-0000-0000-0000-000000000000");
|
} while (tempType == PartType::unusedPartType);
|
||||||
partitionType = tempType;
|
partitionType = tempType;
|
||||||
cout << "Changed type of partition to '" << partitionType.TypeName() << "'\n";
|
cout << "Changed type of partition to '" << partitionType.TypeName() << "'\n";
|
||||||
if (changeName) {
|
if (changeName) {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ using namespace std;
|
|||||||
int PartType::numInstances = 0;
|
int PartType::numInstances = 0;
|
||||||
AType* PartType::allTypes = NULL;
|
AType* PartType::allTypes = NULL;
|
||||||
AType* PartType::lastType = 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
|
// 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.
|
// 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
|
static AType* lastType; // Pointer to last entry in the list
|
||||||
void AddAllTypes(void);
|
void AddAllTypes(void);
|
||||||
public:
|
public:
|
||||||
|
// PartType with GUID "00000000-0000-0000-0000-000000000000"
|
||||||
|
static const PartType unusedPartType;
|
||||||
|
|
||||||
PartType(void);
|
PartType(void);
|
||||||
PartType(const PartType & orig);
|
PartType(const PartType & orig);
|
||||||
PartType(const GUIDData & orig);
|
PartType(const GUIDData & orig);
|
||||||
|
|||||||
Reference in New Issue
Block a user