AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Projekte [Optimiert] Explode Prozedur - Reloaded (Ersatz für CodeLib)
Thema durchsuchen
Ansicht
Themen-Optionen

[Optimiert] Explode Prozedur - Reloaded (Ersatz für CodeLib)

Ein Thema von alzaimar · begonnen am 9. Dez 2006 · letzter Beitrag vom 17. Aug 2010
Antwort Antwort
Benutzerbild von stoxx
stoxx

Registriert seit: 13. Aug 2003
1.111 Beiträge
 
#1

Re: [Optimiert] Explode Prozedur - Reloaded (Ersatz für Code

  Alt 25. Feb 2008, 15:27
hmmm .. weiß jemand was der da tut??

Könnte man die Operationen auch so gestalten, dass es auch mit einem beliebigen Zeichen funktioniert?
Oder ist diese Arithmetik nur für Null einsetzbar?


Delphi-Quellcode:
function StrLen_JOH_PAS_3_a(const Str: PChar): Cardinal;
var
  P, PStr: PChar;
  I, J: Integer;
begin
  if Str^ = #0 then
    begin
      Result := 0; Exit;
    end;
  if Str[1] = #0 then
    begin
      Result := 1; Exit;
    end;
  if Str[2] = #0 then
    begin
      Result := 2; Exit;
    end;
  if Str[3] = #0 then
    begin
      Result := 3; Exit;
    end;
 P := Pointer(Str);
 PStr := P;
 P := Pointer(Integer(P) and -4);
 repeat
   Inc(P, 4);
   I := PInteger(P)^;
   J := I - $01010101;
   I := not(I);
   I := I and J;
 until (I and $80808080) <> 0;
 Result := P - PStr;
 if I and $80 = 0 then
   if I and $8000 <> 0 then
     Inc(Result)
   else
     if I and $800000 <> 0 then
       Inc(Result, 2)
     else
       Inc(Result, 3)
end;
ist vom Benchmark doppelt so schnell, wie eine einfache schleife und jedes Byte anzusehen ..

Delphi-Quellcode:
function StrLen_JOH_PAS_1_a(const Str: PChar): Cardinal;
var
  P : PChar;
begin
  P := Str;
  while P^ <> #0 do
    Inc(P);
  Result := P - Str;
end;
Phantasie ist etwas, was sich manche Leute gar nicht vorstellen können.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:45 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz