replace use of stringstream with boost::lexical_cast

Bug #621331 reported by Monty Taylor on 2010-08-20
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Drizzle
High
Billy Earney
7.0
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) on 2010-08-21
tags: added: low-hanging-fruit
Monty Taylor (mordred) on 2010-08-21
Changed in drizzle:
importance: Undecided → High
status: New → Triaged
Lee Bieber (kalebral) on 2010-08-27
Changed in drizzle:
assignee: nobody → Monty Taylor (mordred)
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?

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.

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

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

Billy Earney (billy-earney) wrote :

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

Lee Bieber (kalebral) 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));
>
>
>

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

Other bug subscribers