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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c32f6f0b23106020,start X-Google-Attributes: gid103376,public From: Johan Groth Subject: Large strings in ADA Date: 2000/04/16 Message-ID: <38FA3003.A38D7B51@xpress.se>#1/1 X-Deja-AN: 611981405 Content-Transfer-Encoding: 7bit X-Accept-Language: en, sv Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@algo.net X-Trace: zingo.tninet.se 955919834 24595 195.162.64.36 (16 Apr 2000 21:17:14 GMT) Organization: Telenordia Mime-Version: 1.0 NNTP-Posting-Date: 16 Apr 2000 21:17:14 GMT Newsgroups: comp.lang.ada Date: 2000-04-16T21:17:14+00:00 List-Id: Hello, I'm trying to write a program that converts a couple of types to strings and are concatenated into one large string that is at the moment a unbounded_string but when the string gets about 50KB big it takes longer and longer to append to it. The code looks like below. I need to concatenate about 2.5MB of data. What is the fasted way to do that in ADA? Just for comparison a similar program in C takes about one second. Can anyone help me? TIA, Johan procedure Main is type String32 is record Info : String(1..32) := (others => ' '); Len : Natural range 0 .. 32 := 0; end record; Str : String32; No : Basic_Integer; Flt : Basic_Float; Msg : Unbounded_String := Null_Unbounded_String; Last : Natural; procedure Append_To_Msg (Str : in String; Max_Len : in Natural; Message : in out Asu.Unbounded_String; Last : in out Natural) is begin Append(Message, " "); Append(Message, Natural'Image(Max_Len)); Append(Message, " "); Append(Message, Str); Last := Asu.Length (Message); end Add_To_Message; begin Str.info(1..6) := "hejsan"; Str.Len := 6; No := 10; Flt := 5.5; for I in 1 .. 1600 loop Append_To_Msg(Str.Info, Basic_Natural(Str.Len), Msg, Last); if (I mod 100) = 0 then Put(" " & Integer'Image(I)); end if; end loop; Put_Line("finished"); exception when Str: others => Put_Line("exception in main: " & Ada.Exceptions.Exception_Name(Str)); end; -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- "Better to ask questions and seem stupid than not to ask questions and remain stupid" -Unknown Johan Groth Kupolen Data