Optimize the code to not call StrToBuf when DataLength is 0.
authorRuiyu Ni <ruyu.ni@intel.com>
Tue, 21 Jan 2014 07:34:41 +0000 (07:34 +0000)
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 21 Jan 2014 07:34:41 +0000 (07:34 +0000)
Signed-off-by: Ruiyu Ni <ruyu.ni@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15143 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c

index 008ec0b96c7480beb64d1c980c99230e52b5fdf7..37d7a1752b76a67222c1dd641f8cd2c9cf3a91ff 100644 (file)
@@ -567,7 +567,9 @@ DevPathFromTextGenericPath (
            (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength)\r
            );\r
 \r
            (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength)\r
            );\r
 \r
-  StrToBuf ((UINT8 *) (Node + 1), DataLength, DataStr);\r
+  if (DataLength != 0) {\r
+    StrToBuf ((UINT8 *) (Node + 1), DataLength, DataStr);\r
+  }\r
   return Node;\r
 }\r
 \r
   return Node;\r
 }\r
 \r