VirtualBox

Changeset 98084 in vbox


Ignore:
Timestamp:
Jan 15, 2023 2:23:39 AM (2 years ago)
Author:
vboxsync
Message:

Main/ConsoleImpl: Another small getDeviceActivity optimization, reducing the code by 16 bytes on windows. bugref:9892

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r98082 r98084  
    28322832     */
    28332833
    2834     /* Make a roadmap of which DeviceType_T LED types are wanted */
    2835     DeviceType_T maxWanted = (DeviceType_T)0;
    2836     bool aWanted[DeviceType_End] = { 0 };
    2837     Assert(aWanted[1] == false && aWanted[DeviceType_End - 1] == false);
     2834    /*
     2835     * Make a roadmap of which DeviceType_T LED types are wanted:
     2836     */
     2837    uint32_t fWanted = 0;
     2838    AssertCompile(DeviceType_End <= 32);
    28382839
    28392840    for (size_t iType = 0; iType < aType.size(); ++iType)
     
    28422843        AssertReturn(enmType > DeviceType_Null && enmType < DeviceType_End,
    28432844                     setError(E_INVALIDARG, tr("Invalid DeviceType for getDeviceActivity in entry #%u: %d"), iType, enmType));
    2844         aWanted[enmType] = true;
    2845         if (enmType > maxWanted)
    2846             maxWanted = enmType;
     2845        fWanted |= RT_BIT_32((unsigned)enmType);
    28472846    }
    28482847
     
    28502849    aActivity.resize(aType.size());
    28512850
    2852     /* Collect all the LEDs in a single sweep through all drivers' sets */
     2851    /*
     2852     * Collect all the LEDs in a single sweep through all drivers' sets:
     2853     */
    28532854    PDMLEDCORE aLEDs[DeviceType_End] = { {0} };
    28542855    Assert(aLEDs[1].u32 == 0 && aLEDs[DeviceType_End / 2].u32 == 0 && aLEDs[DeviceType_End - 1].u32 == 0); /* paranoia */
     
    28642865            {
    28652866                DeviceType_T const enmType = pLS->paSubTypes[inSet];
    2866                 if (enmType < maxWanted && aWanted[enmType])
     2867                Assert((unsigned)enmType < (unsigned)DeviceType_End);
     2868                if (fWanted & RT_BIT_32((unsigned)enmType))
    28672869                    aLEDs[enmType].u32 |= readAndClearLed(pLS->papLeds[inSet]);
    28682870            }
     
    28722874        {
    28732875            DeviceType_T const enmType = pLS->enmType;
    2874             if (enmType < maxWanted && aWanted[enmType])
     2876            Assert((unsigned)enmType < (unsigned)DeviceType_End);
     2877            if (fWanted & RT_BIT_32((unsigned)enmType))
    28752878                for (uint32_t inSet = 0; inSet < pLS->cLeds; ++inSet)
    28762879                    aLEDs[enmType].u32 |= readAndClearLed(pLS->papLeds[inSet]);
     
    28782881    }
    28792882
    2880     /* Compose the result vector: */
     2883    /*
     2884     * Compose the result vector:
     2885     */
    28812886    for (size_t iType = 0; iType < aActivity.size(); ++iType)
    28822887    {
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