Ver código fonte

* Fix bug #34087: Small optimization of StrlComp

git-svn-id: trunk@39563 -
michael 7 anos atrás
pai
commit
08d574bf7d
1 arquivos alterados com 6 adições e 3 exclusões
  1. 6 3
      packages/regexpr/src/regexpr.pas

+ 6 - 3
packages/regexpr/src/regexpr.pas

@@ -760,13 +760,16 @@ function StrLComp (Str1, Str2: PRegExprChar; MaxLen: PtrUInt): PtrInt;
 
 var
   S1, S2: RegExprString;
-
 begin
   S1 := Str1;
   S2 := Str2;
-  if Copy (S1, 1, MaxLen) > Copy (S2, 1, MaxLen) then
+  if Length(S1) > MaxLen then
+    SetLength(S1, MaxLen);
+  if Length(S2) > MaxLen then
+    SetLength(S2, MaxLen);
+  if S1 > S2 then
     Result := 1
-  else if Copy (S1, 1, MaxLen) < Copy (S2, 1, MaxLen) then
+  else if S2 < S2 then
     Result := -1
   else
     Result := 0;