From 3c910d61cd6ae35c18b3aa5e6429f33de7330508 Mon Sep 17 00:00:00 2001 From: Volker Lanz Date: Fri, 9 Jan 2009 09:25:59 +0000 Subject: [PATCH] Use a foreach instead of a while in insertUnallocated(). Also, no need to check if the free space is large enough: createUnallocated() will return NULL if it isn't and PartitionNode::insert() can deal with that. svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=908086 --- src/core/partitiontable.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/core/partitiontable.cpp b/src/core/partitiontable.cpp index a440bda..01921ea 100644 --- a/src/core/partitiontable.cpp +++ b/src/core/partitiontable.cpp @@ -504,20 +504,15 @@ void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64 Q_ASSERT(p != NULL); qint64 lastEnd = start; - qint32 i = 0; - while (i < p->children().size()) + foreach (Partition* child, p->children()) { - Partition* child = p->children()[i]; - - if (child->firstSector() - lastEnd >= d.cylinderSize()) - p->insert(createUnallocated(d, *p, lastEnd, child->firstSector() - 1)); + p->insert(createUnallocated(d, *p, lastEnd, child->firstSector() - 1)); if (child->roles().has(PartitionRole::Extended)) insertUnallocated(d, child, child->firstSector()); lastEnd = child->lastSector() + 1; - i++; } // Take care of the free space between the end of the last child and the end