]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Apply BaseMemoryLib to replace the for loop.
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 14 Jan 2009 14:11:28 +0000 (14:11 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 14 Jan 2009 14:11:28 +0000 (14:11 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7278 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/BasePrintLib/BasePrintLib.inf
MdePkg/Library/BasePrintLib/PrintLibInternal.c
MdePkg/Library/BasePrintLib/PrintLibInternal.h

index 4165d5a31efe029c7e47d3bef164393e97c44328..21d6c20a459d2add9685dce95787cd7bff122921 100644 (file)
@@ -40,4 +40,4 @@
 [LibraryClasses]\r
   DebugLib\r
   BaseLib\r
-\r
+  BaseMemoryLib\r
index 6f0f5e54389b5301f6a4adb69399726f381bb956..3e1d5484a7e7d106c059dd9695e1155f0f898f9c 100644 (file)
@@ -76,20 +76,17 @@ BasePrintLibFillBuffer (
   IN  INTN    Increment\r
   )\r
 {\r
-  INTN  Index;\r
-  if(Increment != 1) {\r
-    for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) {\r
-      *Buffer       =  (CHAR8) Character;\r
-      *(Buffer + 1) =  (CHAR8) (Character >> 8);\r
-      Buffer += Increment;\r
-    }\r
+  UINTN       FillBufferSize;\r
+\r
+  if(Increment == 1) {\r
+    FillBufferSize = MIN (Length, (EndBuffer - Buffer));\r
+    Buffer = SetMem (Buffer, FillBufferSize, (UINT8) Character);\r
   } else {\r
-    for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) {\r
-      *Buffer       =  (CHAR8) Character;\r
-      Buffer += Increment;\r
-    }\r
+    FillBufferSize = MIN (Length << 1, (EndBuffer - Buffer));\r
+    Buffer = SetMem16 (Buffer, FillBufferSize, (UINT16) Character);\r
   }\r
-  return Buffer;\r
+  \r
+  return Buffer + FillBufferSize;\r
 }\r
 \r
 /**\r
@@ -98,7 +95,7 @@ BasePrintLibFillBuffer (
   Print worker function that convert a decimal number to a string in Buffer.\r
 \r
   @param  Buffer    Location to place the Unicode or ASCII string of Value.\r
-  @param  Value     Value to convert to a Decimal or Hexidecimal string in Buffer.\r
+  @param  Value     Value to convert to a Decimal or Hexadecimal string in Buffer.\r
   @param  Radix     Radix of the value\r
 \r
   @return Number of characters printed.\r
index 417d3e60f0c112cf2bf838c65abb6baccb21009b..151ea618983a9c76ba546e8ca2a61e515a43eebe 100644 (file)
@@ -19,6 +19,7 @@
 #include <Library/PrintLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
 \r
 \r
 //\r
@@ -138,7 +139,7 @@ BasePrintLibFillBuffer (
   Print worker function that convert a decimal number to a string in Buffer.\r
 \r
   @param  Buffer    Location to place the Unicode or ASCII string of Value.\r
-  @param  Value     Value to convert to a Decimal or Hexidecimal string in Buffer.\r
+  @param  Value     Value to convert to a Decimal or Hexadecimal string in Buffer.\r
   @param  Radix     Radix of the value\r
 \r
   @return Number of characters printed.\r