Ver código fonte

* Small optimization in CompareStr as suggested in bug ID #30777

git-svn-id: trunk@35601 -
michael 8 anos atrás
pai
commit
e2d704cc8d
1 arquivos alterados com 8 adições e 2 exclusões
  1. 8 2
      rtl/objpas/sysutils/sysstr.inc

+ 8 - 2
rtl/objpas/sysutils/sysstr.inc

@@ -198,12 +198,18 @@ end;
 
 function CompareMemRange(P1, P2: Pointer; Length: PtrUInt): integer;{$ifdef SYSUTILSINLINE}inline;{$endif}
 begin
-  Result:=CompareByte(P1^,P2^,Length);
+  If P1=P2 then 
+    Result:=0
+  else  
+    Result:=CompareByte(P1^,P2^,Length);
 end;
 
 function CompareMem(P1, P2: Pointer; Length: PtrUInt): Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
 begin
-  Result:=CompareByte(P1^,P2^,Length)=0;
+  if P1=P2 then
+    Result:=True
+  else 
+    Result:=CompareByte(P1^,P2^,Length)=0;
 end;