Boost logo

Boost :

Subject: Re: [boost] [xpressive] Performance Tuning?
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2009-07-28 09:33:46


OvermindDL1 wrote:
> On Tue, Jul 28, 2009 at 6:44 AM, Stewart,
> Robert<Robert.Stewart_at_[hidden]> wrote:
> >> P.S. I would be quite happy if anyone could get rid of that
> >> freakishly long double->int64_t cast warning in the
> >> xpressive code, I like clean builds. :)
> >
> > I don't get the warning, so you'll have to be more specific.
>
> Here are the warnings I get, there are two, the first is
> plain and basic:
> 1>r:\programming_projects\spirit_price\price_parsing\main.cpp(789) :
> warning C4244: '=' : conversion from 'const boost::int64_t' to
> 'double', possible loss of data
>
> Although this is with the above ejg file set I posted so the line
> number might be wrong, the line of code is: value = _result /
> denominator;

Hmmm, the only warnings I ever got were from double to int64_t. There is, of course, a precision issue between the two types, but they don't apply to this context, so simply change the line to:

   value = static_cast<double>(_result / denominator);

> The other warning is apparently a single xpressive warning about a
> conversion from int64_t to double. The line of code in main.hpp it
> references is:
> const sregex price =
> *blank
> >> !sign
> >> (real | mixed_number | fraction | integer)
> >> *space;
>
> And the long error is (this outdoes even the sizable spirit error
> message ;-) How I wish we were getting concepts in C++1x, I still do
> not understand why they took it out):

There was still a lot of experimentation, discussion, and twiddling going on. Read http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2906.pdf. Better to get everything else out the door sooner than later.

> Hmm, apparently too big to post on this list (over 800kb, yes, for one
> error message from xpressive). I put it in a text file, zipped it up,
> and attached it, now 6kb.

I'm not certain what is causing that warning. I have three suggestions:

1. In xpressive_parsing::to_price_impl::operator ()(Value const &, Value const &), change "lcm.as<double>() * numerator / denominator" to "lcm.as<double>() * static_cast<double>(numerator) / static_cast<double>(denominator)" (Perhaps only one cast is actually needed)

2. In xpressive_parsing::to_price_impl::operator ()(Value const &, double), change "lcm.as<double>() * whole + _fraction" to "lcm.as<double>() * static_cast<double>(whole) + static_cast<double>(_fraction)" (Perhaps only one cast is actually needed)

3. Simplify the regex to isolate the source. Remove ">> (real | mixed_number | fraction | integer)" first. If that eliminates the warning, then put ">> real" back in. If still no warning, change it to ">> (real | mixed_number)," etc.

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk