Registriert seit: 23. Jan 2008
3.686 Beiträge
Delphi 2007 Enterprise
|
AW: XE2 Stringfunktion + ASM code : function CountString(...)
21. Sep 2011, 15:12
Himiiii! "while true" und "Exit" - wo komms du denn her?
Delphi-Quellcode:
function CountString(const SubStr, S: String): Integer;
var
i: Integer;
begin
Result := 0;
i := 0;
repeat
i := PosEx(SubStr, S, i + 1);
if i > 0 then
Inc(Result);
// oder
Inc(Result, IfThen(Result>0, 1, 0));
// Könnte nur langsamer sein
until i = 0;
end;
"When one person suffers from a delusion, it is called insanity. When a million people suffer from a delusion, it is called religion." (Richard Dawkins)
Geändert von Medium (21. Sep 2011 um 15:19 Uhr)
|