線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1140
推到 Plurk!
推到 Facebook!

我的CPU為什麼會100%呀,代碼正确也不行

答題得分者是:william
hua2000
中階會員


發表:102
回覆:200
積分:65
註冊:2006-11-04

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-03-20 13:51:48 IP:218.20.xxx.xxx 未訂閱
我的CPU為什麼會100%呀,代碼正确也不行 看下面的代碼: Function CompareTwoString(AText,SubText:string):boolean; begin if ansiSame(leftstr(AText,length(SubText)),SubText) then result:=True else result:=False; end; 目的是比較AText的開始部分與subText一樣就TRUE; 對于比較3-5M的文件就會使CPU100%,這應該怎麼辦呀? IMPROVE FOREVER
Justmade
版主


發表:94
回覆:1934
積分:2030
註冊:2003-03-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-03-20 14:08:32 IP:218.16.xxx.xxx 未訂閱
試試  Function CompareTwoString(Const AText,SubText:string):boolean; 也可試試將 Const 改 Var 看看時間有沒分別。
hua2000
中階會員


發表:102
回覆:200
積分:65
註冊:2006-11-04

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-03-20 14:23:48 IP:218.20.xxx.xxx 未訂閱
還是不行呀,一樣的CPU100%呀 另外有沒有用WORLD外理的解決方法呀 IMPROVE FOREVER
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-03-20 14:31:18 IP:147.8.xxx.xxx 未訂閱
Try this one..    
Function CompareTwoString(const AText,SubText:string):boolean;
begin
    Result := (PosEx(SubText,AText)=1);
end;
Are you sure most cpu time is spent on this function?
hua2000
中階會員


發表:102
回覆:200
積分:65
註冊:2006-11-04

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-03-20 15:34:13 IP:218.20.xxx.xxx 未訂閱
這個POSEX是干什麼的呀? 我用我上面的代碼,我的電腦就會停止反應呀! I'm sure of that. IMPROVE FOREVER
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-03-20 15:45:10 IP:147.8.xxx.xxx 未訂閱
Quoted from Delphi help:    function PosEx(const SubStr, S: string; Offset: Cardinal = 1): Integer; C syntax: extern PACKAGE int __fastcall PosEx(const AnsiString SubStr, const AnsiString S, unsigned Offset = 1); Description PosEx returns the index of SubStr in S, beginning the search at Offset. If Offset is 1 (default), PosEx is equivalent to Pos. PosEx returns 0 if SubStr is not found, if Offset is greater than the length of S, or if Offset is less than 1. If you are aiming at case insensitive compare, then PosEx is a good choice, otherwise I think you need to do a little bit more work... >>
hua2000
中階會員


發表:102
回覆:200
積分:65
註冊:2006-11-04

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-03-20 20:17:05 IP:218.20.xxx.xxx 未訂閱
William. Thanks! You are so lovely! Using the 'posex',i've done it successfully! IMPROVE FOREVER
系統時間:2024-05-07 18:55:09
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!