huh???

Thiago Macieira thiago.macieira at kdemail.net
Wed Apr 28 16:37:23 BST 2004


George Staikos wrote:
>Out of curiousity, can anyone explain this code?  Thanks :)
>
>void KMdiMainFrm::removeFromActiveDockList(KMdiDockContainer* td) {
>  for (int i=0;i<4;i++) {
>    if (d->activeDockPriority[i]==td) {
>      // FIXME: HUH??  i2 is never used here, and this for() loop
> modifies the //        variable from the outer loop!!
>      for (int i2=i;i<3;i++)
>        d->activeDockPriority[i]=d->activeDockPriority[i+1];
>      d->activeDockPriority[3]=0;
>      break;
>    }
>  }
>}

i2 is indeed never used. It's useless there.

However, the code seems safe. It finds the first matching in 
activeDockPriority, then bumps up the priority for the rest of the 
elements (3 becomes 2, 2 becomes 1, and so forth).

Since there's a break inside the if, the code is safe to modify the 
outer loop variable.

-- 
  Thiago Macieira  -  Registered Linux user #65028
   thiago (AT) macieira (DOT) info
    ICQ UIN: 1967141   PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20040428/e7171f01/attachment.sig>


More information about the kde-core-devel mailing list