From bcccf0b071386f25def10d6b088b1615b9505f11 Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Wed, 14 Jan 2009 14:11:28 +0000 Subject: [PATCH] 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 --- MdePkg/Library/BasePrintLib/BasePrintLib.inf | 2 +- .../Library/BasePrintLib/PrintLibInternal.c | 23 ++++++++----------- .../Library/BasePrintLib/PrintLibInternal.h | 3 ++- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/MdePkg/Library/BasePrintLib/BasePrintLib.inf b/MdePkg/Library/BasePrintLib/BasePrintLib.inf index 4165d5a31e..21d6c20a45 100644 --- a/MdePkg/Library/BasePrintLib/BasePrintLib.inf +++ b/MdePkg/Library/BasePrintLib/BasePrintLib.inf @@ -40,4 +40,4 @@ [LibraryClasses] DebugLib BaseLib - + BaseMemoryLib diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c index 6f0f5e5438..3e1d5484a7 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c @@ -76,20 +76,17 @@ BasePrintLibFillBuffer ( IN INTN Increment ) { - INTN Index; - if(Increment != 1) { - for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) { - *Buffer = (CHAR8) Character; - *(Buffer + 1) = (CHAR8) (Character >> 8); - Buffer += Increment; - } + UINTN FillBufferSize; + + if(Increment == 1) { + FillBufferSize = MIN (Length, (EndBuffer - Buffer)); + Buffer = SetMem (Buffer, FillBufferSize, (UINT8) Character); } else { - for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) { - *Buffer = (CHAR8) Character; - Buffer += Increment; - } + FillBufferSize = MIN (Length << 1, (EndBuffer - Buffer)); + Buffer = SetMem16 (Buffer, FillBufferSize, (UINT16) Character); } - return Buffer; + + return Buffer + FillBufferSize; } /** @@ -98,7 +95,7 @@ BasePrintLibFillBuffer ( 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 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 @return Number of characters printed. diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.h b/MdePkg/Library/BasePrintLib/PrintLibInternal.h index 417d3e60f0..151ea61898 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.h +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.h @@ -19,6 +19,7 @@ #include #include #include +#include // @@ -138,7 +139,7 @@ BasePrintLibFillBuffer ( 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 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 @return Number of characters printed. -- 2.39.2