replace use of stringstream with boost::lexical_cast

Bug #621331 reported by Monty Taylor
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Drizzle
Fix Released
High
Billy Earney
7.0
Fix Released
Undecided
Billy Earney

Bug Description

There are many places in the code where we use stringstream for type conversions. It usually goes something like this:

stringstream s;
s << some_int_value;
string string_val(s.str());

In fact, probably every use of stringstream is simply for this reason.

These should be replaced with boost::lexical_cast, which will instead look like this:

string string_val(boost::lexical_cast<string>(some_int_value));

Monty Taylor (mordred)
tags: added: low-hanging-fruit
Monty Taylor (mordred)
Changed in drizzle:
importance: Undecided → High
status: New → Triaged
Changed in drizzle:
assignee: nobody → Monty Taylor (mordred)
Revision history for this message
Damon Houk (damon.houk) wrote :

explain_plan.cc:398

s << uppercase << hex << tmp.to_ulong();

iostream conversion offers convenient formatting options. In general, where formatting is essential to the conversion I assume keeping the stringstream conversion is desired. Is this a correct assumption?

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

Damon: yes. For more information please see http://www.gotw.ca/publications/mill19.htm especially Table 2 at the bottom.

This bug report is more about simple, straight conversions.

Revision history for this message
Billy Earney (billy-earney) wrote :

Monty,

I've been wanting to contribute some code to drizzle for a while, and this request seemed simple enough for me to give it a try. I've pushed my changes to lp:~billy-earney/drizzle/bug621331 Please take a look when you have time. currently I've only commented out the code that was replaced. I've ran it against all tests and it seems to pass. Let me know if you see something that should be changed..

Billy

Revision history for this message
Monty Taylor (mordred) wrote : Re: [Bug 621331] Re: replace use of stringstream with boost::lexical_cast

On 09/19/2010 06:29 PM, Billy Earney wrote:
> Monty,
>
> I've been wanting to contribute some code to drizzle for a while, and
> this request seemed simple enough for me to give it a try. I've pushed
> my changes to lp:~billy-earney/drizzle/bug621331 Please take a look
> when you have time. currently I've only commented out the code that was
> replaced. I've ran it against all tests and it seems to pass. Let me
> know if you see something that should be changed..

Hi Billy!

First of all, thanks! I'm always thrilled to get new folks contributing.

First issue ... it doesn't look like your changes made it to launchpad.
The branch you referenced is there, but it only has current trunk
revisions in it. Did you commit before pushing? Could you try pushing again?

Thanks!
Monty

Revision history for this message
Billy Earney (billy-earney) wrote :

I didn't commit before pushing.. Sorry, try it again.

Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote :

Hi BIlly,
Now that you have pushed your branch, please click on "Propose for Merging"
and then someone will review your code.

Thanks, Lee

On Mon, Sep 20, 2010 at 3:33 PM, Billy Earney <email address hidden>wrote:

> I didn't commit before pushing.. Sorry, try it again.
>
> --
> replace use of stringstream with boost::lexical_cast
> https://bugs.launchpad.net/bugs/621331
> You received this bug notification because you are a member of Drizzle-
> developers, which is subscribed to Drizzle.
>
> Status in A Lightweight SQL Database for Cloud Infrastructure and Web
> Applications: Triaged
>
> Bug description:
> There are many places in the code where we use stringstream for type
> conversions. It usually goes something like this:
>
> stringstream s;
> s << some_int_value;
> string string_val(s.str());
>
> In fact, probably every use of stringstream is simply for this reason.
>
> These should be replaced with boost::lexical_cast, which will instead look
> like this:
>
> string string_val(boost::lexical_cast<string>(some_int_value));
>
>
>

Changed in drizzle:
assignee: Monty Taylor (mordred) → Billy Earney (billy-earney)
Changed in drizzle:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.