VirtualBox

Changeset 35074 in vbox


Ignore:
Timestamp:
Dec 14, 2010 1:15:29 PM (14 years ago)
Author:
vboxsync
Message:

Main/Settings: combine loops to speed up version bump checks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xml/Settings.cpp

    r35040 r35074  
    44364436    }
    44374437
    4438     // Settings version 1.11 is required if more than one controller of each type
    4439     // is present.
     4438    // settings version 1.9 is required if there is not exactly one DVD
     4439    // or more than one floppy drive present or the DVD is not at the secondary
     4440    // master; this check is a bit more complicated
     4441    //
     4442    // settings version 1.10 is required if the host cache should be disabled
     4443    //
     4444    // settings version 1.11 is required for bandwidth limits and if more than
     4445    // one controller of each type is present.
    44404446    if (m->sv < SettingsVersion_v1_11)
    44414447    {
     4448        // count attached DVDs and floppies (only if < v1.9)
     4449        size_t cDVDs = 0;
     4450        size_t cFloppies = 0;
     4451
     4452        // count storage controllers (if < v1.11)
    44424453        size_t cSata = 0;
    44434454        size_t cScsiLsi = 0;
     
    44474458        size_t cFloppy = 0;
    44484459
     4460        // need to run thru all the storage controllers and attached devices to figure this out
    44494461        for (StorageControllersList::const_iterator it = storageMachine.llStorageControllers.begin();
    44504462             it != storageMachine.llStorageControllers.end();
    44514463             ++it)
    44524464        {
    4453             switch ((*it).storageBus)
     4465            const StorageController &sctl = *it;
     4466
     4467            // count storage controllers of each type; 1.11 is required if more than one
     4468            // controller of one type is present
     4469            switch (sctl.storageBus)
    44544470            {
    44554471                case StorageBus_IDE:
     
    44634479                    break;
    44644480                case StorageBus_SCSI:
    4465                     if ((*it).controllerType == StorageControllerType_LsiLogic)
     4481                    if (sctl.controllerType == StorageControllerType_LsiLogic)
    44664482                        cScsiLsi++;
    44674483                    else
     
    44824498                || cIde > 1
    44834499                || cFloppy > 1)
     4500            {
    44844501                m->sv = SettingsVersion_v1_11;
    4485         }
    4486     }
    4487 
    4488     // Settings version 1.11 is required if Readonly/MultiAttach media
    4489     // are present.
    4490     if (m->sv < SettingsVersion_v1_11)
    4491     {
    4492         /// @todo add code going over all medium attachments and check if
    4493         // they are of type Readonly or MultiAttach.
    4494     }
    4495 
    4496     // settings version 1.9 is required if there is not exactly one DVD
    4497     // or more than one floppy drive present or the DVD is not at the secondary
    4498     // master; this check is a bit more complicated
    4499     //
    4500     // settings version 1.10 is required if the host cache should be disabled
    4501     //
    4502     // settings version 1.11 is required for bandwidth limits
    4503     if (m->sv < SettingsVersion_v1_11)
    4504     {
    4505         // count attached DVDs and floppies (only if < v1.9)
    4506         size_t cDVDs = 0;
    4507         size_t cFloppies = 0;
    4508 
    4509         // need to run thru all the storage controllers and attached devices to figure this out
    4510         for (StorageControllersList::const_iterator it = storageMachine.llStorageControllers.begin();
    4511              it != storageMachine.llStorageControllers.end();
    4512              ++it)
    4513         {
    4514             const StorageController &sctl = *it;
     4502                break; // abort the loop -- we will not raise the version further
     4503            }
     4504
    45154505            for (AttachedDevicesList::const_iterator it2 = sctl.llAttachedDevices.begin();
    45164506                 it2 != sctl.llAttachedDevices.end();
     
    45204510
    45214511                // Bandwidth limitations are new in VirtualBox 4.0 (1.11)
    4522                 if (    (m->sv < SettingsVersion_v1_11)
    4523                      && (att.strBwGroup.length() != 0)
    4524                    )
     4512                if (m->sv < SettingsVersion_v1_11)
    45254513                {
    4526                     m->sv = SettingsVersion_v1_11;
    4527                     break; /* abort the loop -- we will not raise the version further */
     4514                    if (att.strBwGroup.length() != 0)
     4515                    {
     4516                        m->sv = SettingsVersion_v1_11;
     4517                        break; // abort the loop -- we will not raise the version further
     4518                    }
    45284519                }
    45294520
     
    45564547                }
    45574548            }
     4549
     4550            if (m->sv >= SettingsVersion_v1_11)
     4551                break;  // abort the loop -- we will not raise the version further
    45584552        }
    45594553
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette