Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: rational numbers Date: Sun, 19 Sep 2021 11:03:57 +1200 Lines: 49 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net kBFFrC5gLtnHh/TEhTwonAerwNis0djEij0JgHSHKT+vxv+SRF Cancel-Lock: sha1:8Y4Wi8F5OPrvGcr6nwR4EPj17d8= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.c++:81314 On 19/09/2021 02:54, Scott Lurndal wrote: > David Brown writes: >> On 17/09/2021 23:34, Ian Collins wrote: > >>> >>> Maybe a better compiler would help?  With clang++ and -O2: >>> >> Or pretty much any version of gcc with -O2, at least according to my >> tests on >> >> Maybe Scott has unusual options, or an unusual library, or other >> surrounding code that affects the results. > > $ gcc --version > gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7) > Copyright (C) 2013 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > It's what I had on the system I was posting from, and the code > was an illustrative example, not from our proprietary production > code. But you still used it to back up an exaggerated claim regarding the performance of std::string! If you are using such an old compiler for production code, you have made a rod for your own back. >> There are plenty of reasons to dislike C++ output streams (for me, it is >> the moronic design decision of stateful formatting flags that are the >> big problem). > > Indeed, and they're completely unreadable. Until you need to stream non-trivial objects, or anything in a template... >> The quality of code generated for a weird mixture of >> C-style and C++-style, for an operation that is always big and slow, is >> not such a concern. > > snprintf makes a single pass over the formatting string. It's a single > function call. > > output string streams (the "C++" way) has multiple function calls and > generates a shitload of code. This is certainly true. -- Ian