From c4c90866788fe50881160478b097dc9aa4eb999d Mon Sep 17 00:00:00 2001 From: oliviermartin Date: Thu, 31 May 2012 15:28:37 +0000 Subject: [PATCH] ArmPkg: Enhance CompareGuid performance by using CompareMem instead of nested unaligned read calls Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eugene Cohen eugene@hp.com Reviewed-by: Olivier Martin olivier.martin@arm.com git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13409 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPkg/Library/BaseMemoryLibStm/MemLibGuid.c | 12 +----------- ArmPkg/Library/BaseMemoryLibVstm/MemLibGuid.c | 12 +----------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/ArmPkg/Library/BaseMemoryLibStm/MemLibGuid.c b/ArmPkg/Library/BaseMemoryLibStm/MemLibGuid.c index d4e504a013..1d90a8bca2 100755 --- a/ArmPkg/Library/BaseMemoryLibStm/MemLibGuid.c +++ b/ArmPkg/Library/BaseMemoryLibStm/MemLibGuid.c @@ -81,17 +81,7 @@ CompareGuid ( IN CONST GUID *Guid2 ) { - UINT64 LowPartOfGuid1; - UINT64 LowPartOfGuid2; - UINT64 HighPartOfGuid1; - UINT64 HighPartOfGuid2; - - LowPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1); - LowPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2); - HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1); - HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1); - - return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2); + return (CompareMem(Guid1, Guid2, sizeof(GUID)) == 0) ? TRUE : FALSE; } /** diff --git a/ArmPkg/Library/BaseMemoryLibVstm/MemLibGuid.c b/ArmPkg/Library/BaseMemoryLibVstm/MemLibGuid.c index d4e504a013..748c80eadd 100755 --- a/ArmPkg/Library/BaseMemoryLibVstm/MemLibGuid.c +++ b/ArmPkg/Library/BaseMemoryLibVstm/MemLibGuid.c @@ -81,17 +81,7 @@ CompareGuid ( IN CONST GUID *Guid2 ) { - UINT64 LowPartOfGuid1; - UINT64 LowPartOfGuid2; - UINT64 HighPartOfGuid1; - UINT64 HighPartOfGuid2; - - LowPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1); - LowPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2); - HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1); - HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1); - - return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2); + return (CompareMem(Guid1, Guid2, sizeof(GUID) == 0)) ? TRUE : FALSE; } /**