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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: When to use Bounded_String? Date: Thu, 28 Dec 2017 13:00:44 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <0cc30dc8-4528-4e5c-91dd-24dfbe3cbcb2@googlegroups.com> <96764e4c-48df-4042-845e-12341149bc87@googlegroups.com> NNTP-Posting-Host: TliDXSPe+gBSGCqP3SEJ2Q.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.2 Xref: reader02.eternal-september.org comp.lang.ada:49673 Date: 2017-12-28T13:00:44+01:00 List-Id: On 2017-12-28 12:46, Vincent DIEMUNSCH wrote: > Le jeudi 23 novembre 2017 11:04:12 UTC+1, briot.e...@gmail.com a écrit : > >> You could use GNATCOLL.Strings, which provide the short-string-optimization: >> when a string is shorter than 19 or 23 characters (32 bit and 64 bit systems) then >> no allocation takes place. >> They also provide a much larger number of operations than standard strings or >> unbounded_strings, are task safe, and handle unicode. > > Yes, they are really a great improvement. But they would be perfect if : > 1. they handled UTF-8 as the de-facto standard encoding, for strings. You can ignore encoding and use them as if they were UTF-8 > 2. they could see strings as sequences of 32-bits Unicode Code Points (Wide_Wide_Characters). 23 / 4 = 5 characters 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". -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de