VirtualBox

Changeset 93135 in vbox for trunk/src


Ignore:
Timestamp:
Jan 6, 2022 10:02:15 PM (3 years ago)
Author:
vboxsync
Message:

iprt/strncmp.cpp: We try avoid comparing pointers because of signedness issues. Don't read pszStr1 twice, unless the compiler wants to. Fixed horrible style. (Hope it still works.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/strncmp.cpp

    r93130 r93135  
    3939#endif
    4040{
    41     const char* fini = pszStr1+cb;
    42     while (pszStr1 < fini)
     41    while (cb-- > 0)
    4342    {
    44         int res=*pszStr1-*pszStr2;
    45         if (res)
    46             return res;
    47         if (!*pszStr1)
    48             return 0;
    49         ++pszStr1; ++pszStr2;
     43        char const ch1   = *pszStr1++;
     44        int  const iDiff = ch1 - *pszStr2++;
     45        if (iDiff)
     46            return iDiff;
     47        if (!ch1)
     48            break;
    5049    }
    5150    return 0;
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