33 messages in com.mysql.lists.plusplusRe: Two bugs in 2.2.0
FromSent OnAttachments
Joseph Artsimovich12 Feb 2007 09:14 
gary clark12 Feb 2007 14:08 
Warren Young12 Feb 2007 16:27 
gary clark16 Feb 2007 09:53 
Warren Young16 Feb 2007 11:26 
gary clark16 Feb 2007 11:34 
gary clark16 Feb 2007 13:17 
Jonathan Wakely17 Feb 2007 06:53 
gary clark17 Feb 2007 17:59 
James Vanns19 Feb 2007 02:51 
gary clark19 Feb 2007 06:17 
Warren Young20 Feb 2007 04:19 
Joseph Artsimovich20 Feb 2007 05:36 
Jonathan Wakely20 Feb 2007 05:47 
Joseph Artsimovich20 Feb 2007 05:54 
Jonathan Wakely20 Feb 2007 06:00 
Joseph Artsimovich20 Feb 2007 06:23 
Jonathan Wakely20 Feb 2007 06:31 
Warren Young20 Feb 2007 06:46 
gary clark23 Feb 2007 12:50 
Warren Young23 Feb 2007 13:08 
gary clark23 Feb 2007 13:15 
Warren Young23 Feb 2007 15:15 
Ian Miller23 Feb 2007 15:32 
gary clark24 Feb 2007 06:48 
gary clark28 Feb 2007 15:00 
Warren Young01 Mar 2007 14:32 
gary clark01 Mar 2007 15:00 
gary clark19 Mar 2007 09:39 
Warren Young19 Mar 2007 13:25 
gary clark19 Mar 2007 13:27 
Warren Young19 Mar 2007 13:34 
gary clark20 Mar 2007 07:12 
Subject:Re: Two bugs in 2.2.0
From:Joseph Artsimovich (jos@tts.lt)
Date:02/20/2007 05:36:13 AM
List:com.mysql.lists.plusplus

Joseph Artsimovich wrote:

char* Query::preview_char() { std::string const str(sbuffer_.str()); char* s = new char[str.size() + 1]; memcpy(s, str.c_str(), str.size() + 1); }

This makes one more copy than is necessary. Please try the code currently in svn, as it should accomplish the same end without the double copy.

Actually, my code should be faster than yours. An extra call to std::stringbuf::str() in your code will likely be slower than constructing a temporary std::string from another string. On most platforms the former will allocate memory while the latter will use reference counting.