From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bed2755a22ee69a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!tiscali!newsfeed1.ip.tiscali.net!proxad.net!cleanfeed3-b.proxad.net!nnrp20-1.free.fr!not-for-mail Return-Path: From: "Randy Brukardt" To: Subject: RE: Text Processing in Ada 95 Date: Wed, 21 Feb 2007 14:16:01 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Importance: Normal X-Trash-Finder: Limited filtering for message, local (outbound) source X-Virus-Scanned: amavisd-new at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.9rc1 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.ada Message-ID: X-Leafnode-NNTP-Posting-Host: 88.191.17.134 Organization: Guest of ProXad - France NNTP-Posting-Date: 21 Feb 2007 21:25:07 MET NNTP-Posting-Host: 88.191.14.223 X-Trace: 1172089507 news-1.free.fr 28889 88.191.14.223:56348 X-Complaints-To: abuse@proxad.net Xref: g2news2.google.com comp.lang.ada:9381 Date: 2007-02-21T21:25:07+01:00 Rob Norris writes: ... > Currently I'm using text_io which means I have to copy the whole > thing into memory, insert the line > then over write the file with new contents. direct_io is not an > option (varing string lengths) > > What alternatives should I consider for making insertions faster? > (NB retrieval of a line needs to be fairly quick as well). An insertion into a file requires that you're going to have to rewrite everything after the insertion anyway. So there isn't any way to do that cheaply if you have to do it one insertion at a time. Thus my recommendation is to not do it - that is, find a better way to accomplish whatever it is you need to do. For instance, create a file listing the insertions as an adjunct to the original file, and do the merge only on rare occassions. That would allow copying the file only rarely, and allows doing a large number of insertions at once. If you absolutely have do this as you described, Pascal Obry's suggestions are probably the best. My Trash Finder spam filter has to do this to add header lines to stored messages, and it uses Stream_IO to read and write the file (that can be much cheaper than using Text_IO, because it does not need to look for the ends of lines once it has determined the insertion point). Randy.