Explorar o código

* generic implementation of fpc_pchar_length uses IndexByte instead of a simple while loop

git-svn-id: trunk@33490 -
florian %!s(int64=9) %!d(string=hai) anos
pai
achega
2b082d88a6
Modificáronse 1 ficheiros con 3 adicións e 5 borrados
  1. 3 5
      rtl/inc/generic.inc

+ 3 - 5
rtl/inc/generic.inc

@@ -1272,13 +1272,11 @@ end;
 {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 
 
 function fpc_pchar_length(p:pchar):sizeint;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
 function fpc_pchar_length(p:pchar):sizeint;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
-var i : sizeint;
 begin
 begin
-  i:=0;
   if assigned(p) then
   if assigned(p) then
-    while p[i]<>#0 do
-      inc(i);
-  exit(i);
+    Result:=IndexByte(p^,high(Result),0)
+  else
+    Result:=0;
 end;
 end;
 
 
 {$endif ndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$endif ndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}