220 9025 <CANh-dXnHc34a3KYW9z_Ht7E+yfXOobTV4V8X2NZAQECjQci=9A@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Jeffrey Yasskin <jyasskin@google.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: String to T conversions - getting it right
 this time
Date: Mon, 3 Feb 2014 09:46:27 -0800
Lines: 85
Approved: news@gmane.org
Message-ID: <CANh-dXnHc34a3KYW9z_Ht7E+yfXOobTV4V8X2NZAQECjQci=9A@mail.gmail.com>
References: <097fb6c8-56f9-433e-a2f0-8c0f69609bf0@isocpp.org>
 <b3936b96-3ff0-43a9-9337-510f92abae00@isocpp.org> <lcofk5$vfc$1@ger.gmane.org>
 <CAA7U3HOY2CgSbOwBUbgyynNWCWKku=bDM0f_qetGApTP2cwkpA@mail.gmail.com> <lcok30$ohu$1@ger.gmane.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: ger.gmane.org 1391449605 1538 80.91.229.3 (3 Feb 2014 17:46:45 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 3 Feb 2014 17:46:45 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDDM34EO6QDRBCFMX6LQKGQEQ5FJQAI@isocpp.org Mon Feb 03 18:46:53 2014
Return-path: <std-proposals+bncBDDM34EO6QDRBCFMX6LQKGQEQ5FJQAI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oa0-f70.google.com ([209.85.219.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDDM34EO6QDRBCFMX6LQKGQEQ5FJQAI@isocpp.org>)
	id 1WANbe-0006WE-GX
	for gclcip-std-proposals@m.gmane.org; Mon, 03 Feb 2014 18:46:50 +0100
Original-Received: by mail-oa0-f70.google.com with SMTP id m1sf31975165oag.9
        for <gclcip-std-proposals@m.gmane.org>; Mon, 03 Feb 2014 09:46:49 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=vffJ1JBiUy6o2QOChQHNroBfuPmTvgfJZiGRzvxwp9c=;
        b=LXBZgqtG4GWJQ7TeV4BAwYhR/ormVGMygOtmFI+6Q1jSIHPMGrulPv9gDkwaZ0oTjB
         V9znmyojH6OYnbgAzAYbLaj8iN3xHXe4vwDxQJ52hxJsF+Tmx2nPO3CoUBu2LQ0kihds
         S/lEDlDI4ZzJjUxPUTHVUcHXZY/1Tz5O5aPewmPtuuqzfH+Z6ULpefE9pT9orMhgqWi0
         dfevEpMV69cnrYRe6ogGpXEoZCyTdMMvTU/WmF8K6+zhb3u5RFL9oy10Tr5QQ2bBFUQ5
         T4EQU6BykZd8vUcFcKjgXwEhnqnyly+tJU5RHgbHW+RW/0Zb7oTnRlqax5c2f881JRgg
         WS3Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type;
        bh=vffJ1JBiUy6o2QOChQHNroBfuPmTvgfJZiGRzvxwp9c=;
        b=H35iz7tdJ60wCeD7NyW/0zwZ5ofapMfg3o3Act7UzheXQwuN2oXoZUxgRRRUE+Cc6x
         ggWD4NH1BaTlgttbefcuPveZOvxGHEW+88bMKBOnYhoWNw1qEnzZGmRNSPrqJ0OebdBQ
         orVJMoHrark9vNLfZ2lU2XR5GNnpzPW5e2oo3UmUJIxefwCNLF16EsTvMwXIj2RrGEw/
         y3t8E3D73XBnaMRwQ/+uzmfYgqeH4BVVyO4mw9xgx3ENNorGGyw0pqw9URZM/S1kbbEn
         tJvlRIs6dBrhKgHxIYmhnBPnH5GCDYMaMzt2l21wokRX1YZY06VzgIVrL7RI2tklCLJk
         PfoA==
X-Gm-Message-State: ALoCoQnYbqGxxnIl0QSCqdlEfzV2hz0GaWC58FefrPUhTqo67pWwVA72t5uOl9+9tOcWgBP54MaX
X-Received: by 10.42.235.132 with SMTP id kg4mr2209304icb.32.1391449609420;
        Mon, 03 Feb 2014 09:46:49 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.26.40 with SMTP id 37ls1919615qgu.46.gmail; Mon, 03 Feb
 2014 09:46:48 -0800 (PST)
X-Received: by 10.140.31.247 with SMTP id f110mr54388298qgf.58.1391449608681;
        Mon, 03 Feb 2014 09:46:48 -0800 (PST)
Original-Received: from mail-qc0-x233.google.com (mail-qc0-x233.google.com [2607:f8b0:400d:c01::233])
        by mx.google.com with ESMTPS id a3si15296727qam.90.2014.02.03.09.46.48
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Mon, 03 Feb 2014 09:46:48 -0800 (PST)
Received-SPF: pass (google.com: domain of jyasskin@google.com designates 2607:f8b0:400d:c01::233 as permitted sender) client-ip=2607:f8b0:400d:c01::233;
Original-Received: by mail-qc0-f179.google.com with SMTP id e16so11521474qcx.38
        for <std-proposals@isocpp.org>; Mon, 03 Feb 2014 09:46:48 -0800 (PST)
X-Received: by 10.224.120.199 with SMTP id e7mr58095795qar.47.1391449608343;
 Mon, 03 Feb 2014 09:46:48 -0800 (PST)
Original-Received: by 10.229.227.8 with HTTP; Mon, 3 Feb 2014 09:46:27 -0800 (PST)
In-Reply-To: <lcok30$ohu$1@ger.gmane.org>
X-Original-Sender: jyasskin@google.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of jyasskin@google.com designates 2607:f8b0:400d:c01::233 as permitted
 sender) smtp.mail=jyasskin@google.com;       dkim=pass header.i=@google.com;
       dmarc=pass (p=REJECT dis=NONE) header.from=google.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:9025
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/9025>

On Mon, Feb 3, 2014 at 9:36 AM, Matthew Woehlke
<mw_triad@users.sourceforge.net> wrote:
> On 2014-02-03 11:25, Olaf van der Spek wrote:
>>
>> On Mon, Feb 3, 2014 at 5:20 PM, Matthew Woehlke
>> <mw_triad@users.sourceforge.net> wrote:
>>>>
>>>> I'd prefer 07 to be parsed as 7. Most non-dev people probably expect
>>>> this
>>>> as well.
>>>> Is octal still being used?
>>>
>>>
>>>
>>> You can do this by passing base = 10. '0' as a prefix only means base 8
>>> when
>>> passing base = 0 (i.e. detect from prefix).
>>
>>
>> What if I want dec and hex but no octal? ;)
>
>
> That's a fair question :-). (But so is if we should throw out the 0 prefix
> as indicating octal.)
>
> I suppose you could test if the string starts with '0x' and call with either
> in,base=10 or in+2,base=16. Not saying that's ideal, though. (Even if I
> suspect that performance-wise it would be similar to base=0.)
>
>
>>>> What's the problem with strlen()?
>>>
>>>
>>> It requires additional execution cycles that don't provide any real
>>> benefit.
>>> And yes, that *does* matter; there are definitely cases where string to
>>> number conversion is a performance bottleneck, e.g. when reading large
>>> files
>>> of data in textual format. (I say this from actual real-world personal
>>> experience.)
>>
>>
>> Numbers in text files are not nul-terminated.
>
>
> They are if I'm using a CSV or XML parsing library that yields
> NUL-terminated char*. (And I seem to recall that such do exist, i.e. they
> take a char* buffer and substitute NUL at the end of "values".)

FWIW, your CSV or XML parsing library should be changed to return a
string_view or equivalent. It has the size, and is throwing it out,
forcing your number parser to do redundant checks for '\0', which
slows you down.

Yes, I know it will take time to propagate the new interface through
system libraries.

> "What's the problem with strlen()" is that is has potential performance
> implications given char const* input data. I'm not convinced that trying to
> determine if there is any reasonable instance where one has char const* data
> in a situation that is performance sensitive qualifies as reason to
> disregard that.
>
> --
> Matthew
>
>
> --
>
> --- You received this message because you are subscribed to the Google
> Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.
