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 11:15:08 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.mathworks.com!wn13feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!attbi_s01.POSTED!not-for-mail From: Freejack Subject: Re: Strings Fixed, Bounded, and Counted. Performance Inquiry. Newsgroups: comp.lang.ada Message-ID: References: User-Agent: Pan/0.11.4 (Unix) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Comment-To: "Stephen Leake" NNTP-Posting-Host: 12.245.85.50 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s01 1067282107 12.245.85.50 (Mon, 27 Oct 2003 19:15:07 GMT) NNTP-Posting-Date: Mon, 27 Oct 2003 19:15:07 GMT Organization: Comcast Online Date: Mon, 27 Oct 2003 19:15:08 GMT Xref: archiver1.google.com comp.lang.ada:1745 Date: 2003-10-27T19:15:08+00:00 List-Id: On Mon, 27 Oct 2003 12:18:48 -0500, Stephen Leake wrote: >> A bit more flexible than Fixed strings, > > How? It was my understanding(I could be wrong here) that a Fixed string is unmodifiable without access to functions provided in the package. A Counted string is modifiable outside the package provided functions and procedures. No? >> 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. So essentially, with a Fixed string, I can have the compiler generate machine code to grab a block of length X, and shove it into an empty block of length Y if Y > X? All on one I/O procedure? (Thinking of the Linux "sendfile()" and "iovec()" functions here.) I really want to avoid character by character transfer when it's not necessary. Also, if I can read the first element, and see that the string has twenty characters, I can have the program inline a procedure x/20 times, rather than using a Counter and loop structure. >> 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. I am definitely being specific in my package spec. You're right. Aside from a couple quirks of my own design, bounded strings do the right thing. As do Fixed Strings. I'll keep playing with 'em and tell you what I come up with. Heh. Thanks. Freejack