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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,789b3fa522bdcc2a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-01 23:19:51 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!205.188.226.98!ngpeer.news.aol.com!newsfeed1.bredband.com!bredband!newsfeed1.telenordia.se!algonet!uab.ericsson.se!erinews.ericsson.se!news.ericsson.se!not-for-mail From: Frode Tenneboe Newsgroups: comp.lang.ada Subject: Re: Optimising string handling in application Date: Wed, 2 Apr 2003 07:15:52 +0000 (UTC) Organization: Ericsson AS Message-ID: <1049267738.39983@edh3> References: <1049198066.356477@edh3> NNTP-Posting-Host: edh3.edh.ericsson.se Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: newstree.wise.edt.ericsson.se 1049267752 14228 193.180.212.12 (2 Apr 2003 07:15:52 GMT) X-Complaints-To: abuse@ericsson.se NNTP-Posting-Date: Wed, 2 Apr 2003 07:15:52 +0000 (UTC) User-Agent: tin/1.4.1-19991201 ("Polish") (UNIX) (SunOS/5.8 (sun4u)) Cache-Post-Path: edh3!unknown@alne X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/) Xref: archiver1.google.com comp.lang.ada:35878 Date: 2003-04-02T07:15:52+00:00 List-Id: tmoran@acm.org wrote: > Does this (with its questions answered) do what you want? Yes. Thank you. However, since I'm calling this all over the place and need the fixed length types I have reintroduced them to put the gritty stuff in one place: procedure Replace_Callsign_In_Msg (Msg : in out Dpu_Loc_Messages.T_Msg_Data_Str; Msg_Length : in out T_Integer_32; Callsign : in Dpu_Loc_Messages.T_Msg_Callsign; Callsign_Length : in Positive) is Stop_First_String : constant Positive := Ada.Strings.Fixed.Index (Source => Msg(1 .. Msg_Length), Pattern => "ME001=") + 5; Start_Next_String : Positive; begin if Stop_First_String = 5 then -- "ME001=" not present raise Constraint_Error; end if; Start_Next_String := Ada.Strings.Fixed.Index (Source => Msg(Stop_First_String .. Msg_Length), Pattern => ";"); if Start_Next_String = 0 then -- ";" not present raise Constraint_Error; end if; declare Dummy : constant String := Msg (1 .. Stop_First_String) & Callsign(1 .. Callsign_Length) & Msg (Start_Next_String .. Msg_Length); begin Msg_Length := Dummy'Length; Msg (1 .. Msg_Length) := Dummy; end; end Replace_Callsign_In_Msg; Better. Could probably be tuned more, but it's also more readable now. Thanks all. Follow-up question: Is it safe to asume that strings _allways_ start with 'First = 1 (provided the (sub)type starts with 1) except when passing slices where 'First = start_of_slice? -Frode -- ^ Frode Tenneb� | email: Frode.Tennebo@eto.ericsson.se ^ | Ericsson AS., N-1788 Halden | Phone: +47 67 25 09 39 | | with Standard.Disclaimer; use Standard.Disclaimer; |