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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: When to use Bounded_String? Date: Thu, 28 Dec 2017 18:36:19 -0600 Organization: JSA Research & Innovation Message-ID: References: <0cc30dc8-4528-4e5c-91dd-24dfbe3cbcb2@googlegroups.com> <96764e4c-48df-4042-845e-12341149bc87@googlegroups.com> <37c30172-9386-45fb-86d0-a10998fcade8@googlegroups.com> Injection-Date: Fri, 29 Dec 2017 00:36:19 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="17105"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:49684 Date: 2017-12-28T18:36:19-06:00 List-Id: wrote in message news:37c30172-9386-45fb-86d0-a10998fcade8@googlegroups.com... Le jeudi 28 décembre 2017 13:00:46 UTC+1, Dmitry A. Kazakov a écrit : ... >> P.S. Just never copy strings if you have performance concerns (even if >> you have none). Nothing to optimize then. Use string slices, pass string >> + an index to start at, do everything in a single pass, there is no >> reason to waste CPU time, memory and brain cells on "tokenizing". > >True. Except for storing the identifiers in a symbol table... It's probably good advice in general, but as always it depends on the problem in question. If the problem can be solved better by a sequence of transformations rather than something monolithic, then copying is inevitable. For instance, in my spam filter, I have a transformed version of the message that contains just the text (eliminating the markup, line ends, and the like), to be used for phrase matching. Otherwise, the spammer could easily hide bad phrases by including (invisible) markup or line endings. That requires a copy of the string. Randy.