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=-1.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bed2755a22ee69a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news3.google.com!newsfeed2.dallas1.level3.net!newsfeed1.dallas1.level3.net!news.level3.com!news.binc.net!kilgallen From: Kilgallen@SpamCop.net (Larry Kilgallen) Newsgroups: comp.lang.ada Subject: Re: Text Processing in Ada 95 Date: 22 Feb 2007 08:02:20 -0600 Organization: LJK Software Message-ID: References: <45DC988E.7040800@obry.net> NNTP-Posting-Host: eisner.encompasserve.org X-Trace: grandcanyon.binc.net 1172152874 11783 192.135.80.34 (22 Feb 2007 14:01:14 GMT) X-Complaints-To: abuse@binc.net NNTP-Posting-Date: Thu, 22 Feb 2007 14:01:14 +0000 (UTC) Xref: g2news2.google.com comp.lang.ada:9410 Date: 2007-02-22T08:02:20-06:00 List-Id: In article <45DC988E.7040800@obry.net>, Pascal Obry writes: > Rob Norris a �crit : >> 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) > > Use Text_IO ok, but why copy all in memory. Just write to a temp file, > delete the original one and rename the temp file. > >> What alternatives should I consider for making insertions faster? >> (NB retrieval of a line needs to be fairly quick as well). > > If you have a lot of modifications to do on the file, then you probably > need to read all the file in memory to have good performances. In this > case, read file in blocks using Stream_IO. Do the changes in memory and > write it back in blocks using Stream_IO. Or use an operating system feature that allows insertions. GNAT Ada 95 on VMS is supposed to emulate DEC Ada features, so that should include the Mixed_Indexed_IO package. There will be more overhead in disk files but for large files it is much better for inserting data in the middle.