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-7-bit X-Google-Thread: 103376,2d76c4749a82ef0b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-27 09:37:22 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Strings Fixed, Bounded, and Counted. Performance Inquiry. Date: 27 Oct 2003 12:18:48 -0500 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: NNTP-Posting-Host: shevek.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1067275349 6960 128.183.235.101 (27 Oct 2003 17:22:29 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 27 Oct 2003 17:22:29 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Xref: archiver1.google.com comp.lang.ada:1739 Date: 2003-10-27T17:22:29+00:00 List-Id: Freejack writes: > Fixed strings are great in terms of performance. Bounded strings are > pretty good. However I havent seen anyone do a performance analysis of > Counted strings. I'm thinking in the Forth sense of the type. Ah, Forth. Haven't done that in a while. > i.e. The first element of the String is a number indicating the > length of the string. If I recall correctly, Forth strings are all fixed, in the sense that they cannot be modified in place. > No null terminators needed. Correct. > A bit more flexible than Fixed strings, How? > a heck of a lot faster than Null terminated strings. Depends on what you are doing. Copying the strings character by character is the same speed for either construct. Block copy is faster with a count on most machines. But most algorithms for processing strings operate character by character, so it doesn't really matter. Safety is another issue; with a count (or bounds) it is possible to check array indices before fetching or storing. > Not sure how they stack up to Bounded strings. Since Ada fixed strings store the array bounds, that is essentially the same as counted Forth strings. Ada Bounded strings let you change the value in place, so they are more flexible. > Has anyone played with these in an Ada context? Yes, all the time :). > I'm gonna write my own experimental package if nobody else has Be sure you define _precisely_ what you want the package to do, and see if Ada already has it, before you spend time implementing it. -- -- Stephe