Ver Fonte

* Optimize fpc_AnsiStr_Compare to not use exception frame unless codepages differ

git-svn-id: trunk@35620 -
michael há 8 anos atrás
pai
commit
68bb9bef2c
1 ficheiros alterados com 15 adições e 8 exclusões
  1. 15 8
      rtl/inc/astrings.inc

+ 15 - 8
rtl/inc/astrings.inc

@@ -627,6 +627,20 @@ end;
 
 {$ifndef FPC_HAS_ANSISTR_COMPARE}
 {$define FPC_HAS_ANSISTR_COMPARE}
+
+Function fpc_utf8_Compare(const S1,S2 : RawByteString): SizeInt;
+
+var
+  r1,r2 : RawByteString;
+begin
+  r1:=S1;
+  r2:=S2;
+  //convert them to utf8 then compare
+  SetCodePage(r1,65001);
+  SetCodePage(r2,65001);
+  Result:=fpc_AnsiStr_Compare(r1,r2);
+end;
+
 Function fpc_AnsiStr_Compare(const S1,S2 : RawByteString): SizeInt;[Public,Alias : 'FPC_ANSISTR_COMPARE'];  compilerproc;
 {
   Compares 2 AnsiStrings;
@@ -673,14 +687,7 @@ begin
         result:=Length(S1)-Length(S2);
     end
   else
-    begin
-      r1:=S1;
-      r2:=S2;
-      //convert them to utf8 then compare
-      SetCodePage(r1,65001);
-      SetCodePage(r2,65001);
-      Result:=fpc_AnsiStr_Compare(r1,r2);
-    end;
+    Result:=fpc_utf8_compare(s1,s2);
 end;
 {$endif FPC_HAS_ANSISTR_COMPARE}