[Spice-devel] [spice-xpi 2/4] Change SendStr to handle a std::string

Christophe Fergeau cfergeau at redhat.com
Wed Apr 4 07:22:08 PDT 2012


On Wed, Apr 04, 2012 at 04:02:38PM +0200, Peter Hatina wrote:
> Hi,
> 
> On 04/03/2012 04:38 PM, Christophe Fergeau wrote:
> > All callers were using std::string::c_str(), better to move this
> > call to SendStr instead of doing it everywhere.
> > ---
> >  SpiceXPI/src/plugin/plugin.cpp |   28 ++++++++++++++--------------
> >  SpiceXPI/src/plugin/plugin.h   |    2 +-
> >  2 files changed, 15 insertions(+), 15 deletions(-)
> > 
> > diff --git a/SpiceXPI/src/plugin/plugin.cpp b/SpiceXPI/src/plugin/plugin.cpp
> > index 04d272b..008688a 100644
> > --- a/SpiceXPI/src/plugin/plugin.cpp
> > +++ b/SpiceXPI/src/plugin/plugin.cpp
> > @@ -570,16 +570,16 @@ void nsPluginInstance::SendBool(uint32_t id, bool value)
> >      WriteToPipe(&msg, sizeof(msg));
> >  }
> >  
> > -void nsPluginInstance::SendStr(uint32_t id, const char *str)
> > +void nsPluginInstance::SendStr(uint32_t id, std::string str)
> 
> Maybe, you could have used:
> 
> void nsPluginInstance::SendStr(uint32_t id, std::string &str)
> 
> To avoid unnecessary copying. Just a footnote :)

I nearly made the opposite footnote in one of your patches :) I remember
reading somewhere that copying a std::string is cheap enough that we don't
really need to care about passing it by reference. Since I cannot find
where I read that, I'll have to agree with you :) Hope you don't mind if I
leave things this way though? I've pushed the patch this morning
unfortunately...

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20120404/abc4dd0d/attachment.pgp>


More information about the Spice-devel mailing list