为什么,因为见很多人都喜欢用string这个东西,但写函数的时候有些情况不注意,
所以,看看吧,说不定你的程序效率就是因为这个。http://www.delphibbs.com/delphibbs/dispq.asp?LID=1411217当然还有,各位自已找找。
所以,看看吧,说不定你的程序效率就是因为这个。http://www.delphibbs.com/delphibbs/dispq.asp?LID=1411217当然还有,各位自已找找。
什么马甲啊,偶敬仰都来不及,:)不过很少去DFW,在那知道的人也不多,只是看到这篇贴子不错,又看到好几个用string的方法不好,所以介绍给大家。
我知道的DFW的人就几个:左大牛,孙大牛,还有阿朱(这小子写的东西真是不错),卷MM([:D]),5145,呵呵,这些印象比较深,当然还有一些就算了。:)all所谓细微之处见真功夫,大家不要太小觑之,有时程序的问题可能就是最容易的,最基本的地方。耙子哪里走,看我的金古棒来也。
比如有20个HTML文件,要把它们连在一起,有两个最简单的方法实现:
1,一个str:String;一个MEMO,用MEMO来LOAD文件,然后str := str+memo.Text,memo.text := str;如此一直LOAD至MEMO中。
2。两个MEMO,头一个LOAD,然后另一个MEMO2.lines.add(Memo1.text);
这两种方法哪一个快?
str := str+memo.Text,
会花如此长的时间
procedure TForm1.Button1Click(Sender: TObject); procedure Method1;
var
I: Integer;
S: string;
begin
if OpenDialog1.Execute then
begin
S := '';
for I := 0 to OpenDialog1.Files.Count - 1 do
begin
Memo1.Lines.LoadFromFile(OpenDialog1.Files[i]);
S := S + Memo1.Text;
end;
Memo2.Text := S;
end;
end; procedure Method2;
var
I: Integer;
begin
begin
Memo2.Clear;
for I := 0 to OpenDialog1.Files.Count - 1 do
begin
Memo1.Lines.LoadFromFile(OpenDialog1.Files[i]);
Memo2.Lines.Add(Memo1.Text);
end;
end;
end;var
Start1, Start2: Cardinal;
begin
Start1 := GetTickCount;
Method1;
Start2 := GetTickCount;
Method2;
Caption := Format('Method1: %f, Method2: %f', [(Start2 - Start1) / 1000, (GetTickCount - Start2) / 1000]);
end;
http://expert.csdn.net/Expert/topic/1171/1171303.xml?temp=.8061182有好东东。:)