全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1160
推到 Plurk!
推到 Facebook!

大字串的读入

缺席
KFC
一般會員


發表:43
回覆:73
積分:23
註冊:2003-03-27

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-04-14 11:20:42 IP:210.77.xxx.xxx 未訂閱
请问TStringList中怎样快速地读入一个很大的串?我需要处理的字串量很多。而且每一笔都很大。
william
版主


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-04-14 11:29:00 IP:147.8.xxx.xxx 未訂閱
There is no shortcut... Perhaps you should set the proper Capacity before adding string to the string list.
KFC
一般會員


發表:43
回覆:73
積分:23
註冊:2003-03-27

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-04-14 11:32:03 IP:210.77.xxx.xxx 未訂閱
不明白,设了capacity会有改善吗?
william
版主


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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-04-14 11:39:35 IP:147.8.xxx.xxx 未訂閱
From Delphi help on TStringList:    Indicates the number of strings the string list has allocated memory to hold. Delphi syntax: property Capacity: Integer; C syntax: __property int Capacity = {read=FCapacity, write=SetCapacity, nodefault}; Description Use Capacity to find out how much memory is available for holding strings, or to reallocate the memory to allow more or fewer strings. Capacity is the number of entries in the string list that have been allocated, as opposed to Count, which is the number of strings in the list. Thus, Capacity is always greater than or equal to Count. Adding new strings will cause the Capacity property to increase if necessary, but setting the Capacity property will not change the Count property. Do not set Capacity to a value less than Count, or the list will be truncated and Count will indicate that the list contains more strings than is the case. Also, if Capacity is set to a value less than Count, the memory used to store the strings that are dropped from the list (as opposed to the entries in the list that point to those strings) is not freed. Avoid passing strings by value when dealing with huge strings. So using const and var in your functions would be better.
timhuang
尊榮會員


發表:78
回覆:1815
積分:1608
註冊:2002-07-15

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-04-14 22:11:31 IP:61.221.xxx.xxx 未訂閱
引言: 请问TStringList中怎样快速地读入一个很大的串?我需要处理的字串量很多。而且每一笔都很大。
請問你要做什麼樣的處理, 若是一定要讀入 TStringList 的話, 是沒有更快的方法了 , 可以大概說明一下讀入後的處理嗎? 若是一定要先讀入後才能進行處理的話, 可能是沒有更快的方法了..
KFC
一般會員


發表:43
回覆:73
積分:23
註冊:2003-03-27

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-04-14 22:15:18 IP:210.77.xxx.xxx 未訂閱
其实我是对一大堆的邮件进行处理。每封邮件都含附件而且很大。我要将这些邮件一封一封地读入一个邮件处理元件的TStringList中解码。我发现解码过程是非常快的,就是读入过程太慢,造成瓶颈
KFC
一般會員


發表:43
回覆:73
積分:23
註冊:2003-03-27

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-04-14 22:15:29 IP:210.77.xxx.xxx 未訂閱
其实我是对一大堆的邮件进行处理。每封邮件都含附件而且很大。我要将这些邮件一封一封地读入一个邮件处理元件的TStringList中解码。我发现解码过程是非常快的,就是读入过程太慢,造成瓶颈
timhuang
尊榮會員


發表:78
回覆:1815
積分:1608
註冊:2002-07-15

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-04-14 22:43:09 IP:61.221.xxx.xxx 未訂閱
引言: 其实我是对一大堆的邮件进行处理。每封邮件都含附件而且很大。我要将这些邮件一封一封地读入一个邮件处理元件的TStringList中解码。我发现解码过程是非常快的,就是读入过程太慢,造成瓶颈
若是一定要讀入的話, 應該是沒有辦法解決了, willian 兄的方法可以試試看. 若字串很長的話, 應該是可以小幅增進效能的..
系統時間:2024-05-05 2:50:47
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!