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-Thread: 103376,8f802583e5c84fa X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed.pacific.net.au!nasal.pacific.net.au!not-for-mail Newsgroups: comp.lang.ada Subject: Re: String filtering From: David Trudgett Organization: Very little? References: <1j92wa9843ylq.16j89wuqatbaj$.dlg@40tude.net> <433924a2$1_1@glkas0286.greenlnk.net> <43392732$1_1@glkas0286.greenlnk.net> <1jd30obyohnp6$.41tz3funikly.dlg@40tude.net> <43394a3e$1_1@glkas0286.greenlnk.net> Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:nMpHxPhZkIySr2jH0T0Idt1mQA4= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 28 Sep 2005 19:54:35 +1000 NNTP-Posting-Host: 61.8.38.68 X-Complaints-To: news@pacific.net.au X-Trace: nasal.pacific.net.au 1127901554 61.8.38.68 (Wed, 28 Sep 2005 19:59:14 EST) NNTP-Posting-Date: Wed, 28 Sep 2005 19:59:14 EST Xref: g2news1.google.com comp.lang.ada:5229 Date: 2005-09-28T19:54:35+10:00 List-Id: Jacob Sparre Andersen writes: > procedure Strip_Non_Alphanumeric (Str : in out Unbounded_String) is > -- This version does in-place modification of the unbounded > -- string, and is thus actually making use of Str being an > -- unbounded string and not a fixed length string. > Position : Natural := 1; > begin > while Position =< Length (Str) loop > if Is_In (Element (Str, Position), Alpha_Num_Space_Set) then > Position := Position + 1; > else > Delete (Source => Str, > From => Position, > Through => Position); > end if; > end loop; > end Strip_Non_Alphanumeric; > Yes, that works, too, and I've added it in just for completeness. Thanks. (Your =< should have been <= though. There's always something to fix, isn't there? ;-)) > > Good. It makes the String and Unbounded_String versions practically > equivalent - probably both in CPU and memory use. Much of a muchness, I would guess. Profiling particular applications on particular compilers is the only way to tell for sure, though. Thanks for your help, Jacob. David -- David Trudgett http://www.zeta.org.au/~wpower/ There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable. There is another theory which states that this has already happened. -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"