mirror of https://github.com/acidanthera/audk.git
Revised GetPowerOfTwo32() and GetPowerOfTwo64() to be more efficient.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@963 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
0898f77162
commit
3cc092acf2
|
@ -33,8 +33,9 @@ GetPowerOfTwo32 (
|
|||
IN UINT32 Operand
|
||||
)
|
||||
{
|
||||
INTN BitPos;
|
||||
|
||||
BitPos = HighBitSet32 (Operand);
|
||||
return BitPos >= 0 ? 1ul << BitPos : 0;
|
||||
if (Operand == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1ul << HighBitSet32 (Operand);
|
||||
}
|
||||
|
|
|
@ -33,8 +33,9 @@ GetPowerOfTwo64 (
|
|||
IN UINT64 Operand
|
||||
)
|
||||
{
|
||||
INTN BitPos;
|
||||
if (Operand == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
BitPos = HighBitSet64 (Operand);
|
||||
return BitPos >= 0 ? LShiftU64 (1, BitPos) : 0;
|
||||
return LShiftU64 (1, HighBitSet64 (Operand));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue