Apply BaseMemoryLib to replace the for loop.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7278 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8 2009-01-14 14:11:28 +00:00
parent 7646204cdb
commit bcccf0b071
3 changed files with 13 additions and 15 deletions

View File

@ -40,4 +40,4 @@
[LibraryClasses] [LibraryClasses]
DebugLib DebugLib
BaseLib BaseLib
BaseMemoryLib

View File

@ -76,20 +76,17 @@ BasePrintLibFillBuffer (
IN INTN Increment IN INTN Increment
) )
{ {
INTN Index; UINTN FillBufferSize;
if(Increment != 1) {
for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) { if(Increment == 1) {
*Buffer = (CHAR8) Character; FillBufferSize = MIN (Length, (EndBuffer - Buffer));
*(Buffer + 1) = (CHAR8) (Character >> 8); Buffer = SetMem (Buffer, FillBufferSize, (UINT8) Character);
Buffer += Increment;
}
} else { } else {
for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) { FillBufferSize = MIN (Length << 1, (EndBuffer - Buffer));
*Buffer = (CHAR8) Character; Buffer = SetMem16 (Buffer, FillBufferSize, (UINT16) Character);
Buffer += Increment;
} }
}
return Buffer; return Buffer + FillBufferSize;
} }
/** /**
@ -98,7 +95,7 @@ BasePrintLibFillBuffer (
Print worker function that convert a decimal number to a string in Buffer. Print worker function that convert a decimal number to a string in Buffer.
@param Buffer Location to place the Unicode or ASCII string of Value. @param Buffer Location to place the Unicode or ASCII string of Value.
@param Value Value to convert to a Decimal or Hexidecimal string in Buffer. @param Value Value to convert to a Decimal or Hexadecimal string in Buffer.
@param Radix Radix of the value @param Radix Radix of the value
@return Number of characters printed. @return Number of characters printed.

View File

@ -19,6 +19,7 @@
#include <Library/PrintLib.h> #include <Library/PrintLib.h>
#include <Library/BaseLib.h> #include <Library/BaseLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
// //
@ -138,7 +139,7 @@ BasePrintLibFillBuffer (
Print worker function that convert a decimal number to a string in Buffer. Print worker function that convert a decimal number to a string in Buffer.
@param Buffer Location to place the Unicode or ASCII string of Value. @param Buffer Location to place the Unicode or ASCII string of Value.
@param Value Value to convert to a Decimal or Hexidecimal string in Buffer. @param Value Value to convert to a Decimal or Hexadecimal string in Buffer.
@param Radix Radix of the value @param Radix Radix of the value
@return Number of characters printed. @return Number of characters printed.