Tstrings или Array что производительнее?
использую такой код: ниже.. все выполняется очень долго... почти минуту. Если вместо FontNamesList, CharsList - т.е. вместо Tstrings(TstringList) - использовать массивы , и вместо счётчика кол-ва цифр - например сортировку массива, будет ли операция выполняться быстрее?
| Код | var fi,ci:Integer; c,TMPChar:Char; FontNamesList,CharsList : Tstrings; TMPStr,TMPFontStr,CharSymbol : string; Izero,Ione,Itwo,Ithree,Ifour,Ifive,Isix,Iseven,Ieight,Inine : integer; begin FontNamesList:=TstringList.Create; FontNamesList.Clear; FontNamesList.AddStrings(Screen.Fonts); //загружаю примерно 180 штук шрифтнов CharsList:=TstringList.Create; CharsList.Clear; for fi:=0 to FontNamesList.Count-1 do begin TMPFontStr:=FontNamesList.Strings[fi]; c:=GETNumberedChar(TMPFontStr); //получаю цифру в шрифте TMPFontStr if c in ['0','1','2','3','4','5','6','7','8','9'] then CharsList.Add(c); end; Izero:=0; //кол-во нулей Ione:=0; //.. единиц Itwo:=0; //... двоек Ithree:=0; Ifour:=0; Ifive:=0; Isix:=0; Iseven:=0; Ieight:=0; Inine:=0; for ci := 0 to CharsList.Count - 1 do //считаю количесво единиц, двоек, троек и т.д. begin TMPstr:=CharsList.Strings[ci]; case StrToInt(TMPstr) of 0 : Izero:=Izero+1; 1 : Ione:=Ione+1; 2 : Itwo:=Itwo+1; 3 : Ithree:=Ithree+1; 4 : Ifour:=Ifour+1; 5 : Ifive:=Ifive+1; 6 : Isix:=Isix+1; 7 : Iseven:=Iseven+1; 8 : Ieight:=Ieight+1; 9 : Inine:=Inine+1; end; Application.ProcessMessages; end; CharSymbol:='x'; {0} if (Izero>Ione) and (Izero>Itwo) and (Izero>Ithree) and (Izero>Ifour) and (Izero>Ifive) //количество каких единиц больше... and (Izero>Isix) and (Izero>Iseven) and (Izero>Ieight) and (Izero>Inine) //если нулей больше чем других цифр then CharSymbol:='0'; //то CharSymbol:='0'; {1} if (Ione>Izero) and (Ione>Itwo) and (Ione>Ithree) and (Ione>Ifour) and (Ione>Ifive) and (Ione>Isix) and (Ione>Iseven) and (Ione>Ieight) and (Ione>Inine) then CharSymbol:='1'; {2} if (Itwo>Izero) and (Itwo>Ione) and (Itwo>Ithree) and (Itwo>Ifour) and (Itwo>Ifive) and (Itwo>Isix) and (Itwo>Iseven) and (Itwo>Ieight) and (Itwo>Inine) then CharSymbol:='2'; {3} if (Ithree>Ione) and (Ithree>Itwo) and (Ithree>Izero) and (Ithree>Ifour) and (Ithree>Ifive) and (Ithree>Isix) and (Ithree>Iseven) and (Ithree>Ieight) and (Ithree>Inine) then CharSymbol:='3'; {4} if (Ifour>Ione) and (Ifour>Itwo) and (Ifour>Ithree) and (Ifour>Izero) and (Ifour>Ifive) and (Ifour>Isix) and (Ifour>Iseven) and (Ifour>Ieight) and (Ifour>Inine) then CharSymbol:='4'; {5} if (Ifive>Ione) and (Ifive>Itwo) and (Ifive>Ithree) and (Ifive>Ifour) and (Ifive>Izero) and (Ifive>Isix) and (Ifive>Iseven) and (Ifive>Ieight) and (Ifive>Inine) then CharSymbol:='5'; {6} if (Isix>Ione) and (Isix>Itwo) and (Isix>Ithree) and (Isix>Ifour) and (Isix>Ifive) and (Isix>Izero) and (Isix>Iseven) and (Isix>Ieight) and (Isix>Inine) then CharSymbol:='6'; {7} if (Iseven>Ione) and (Iseven>Itwo) and (Iseven>Ithree) and (Iseven>Ifour) and (Iseven>Ifive) and (Iseven>Isix) and (Iseven>Izero) and (Iseven>Ieight) and (Iseven>Inine) then CharSymbol:='7'; {8} if (Ieight>Ione) and (Ieight>Itwo) and (Ieight>Ithree) and (Ieight>Ifour) and (Ieight>Ifive) and (Ieight>Isix) and (Ieight>Iseven) and (Ieight>Izero) and (Ieight>Inine) then CharSymbol:='8'; {9} if (Inine>Ione) and (Inine>Itwo) and (Inine>Ithree) and (Inine>Ifour) and (Inine>Ifive) and (Inine>Isix) and (Inine>Iseven) and (Inine>Ieight) and (Inine>Izero) then CharSymbol:='9'; if CharSymbol='x' then exit;
CharsList.Clear; end;
|
|