When wrapping C++ code, generate code which uses

std::string::assign(PTR, LEN) rather than assigning
std::string(PTR, LEN).  Using assign generates more efficient code
(tested with GCC 4.1.2).


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9936 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2007-09-17 20:10:57 +00:00
commit c836c81acb
11 changed files with 46 additions and 45 deletions

View file

@ -33,14 +33,14 @@ namespace std {
%typemap(in) string {
if (SCHEME_STRINGP($input))
$1 = std::string(SCHEME_STR_VAL($input));
$1.assign(SCHEME_STR_VAL($input));
else
SWIG_exception(SWIG_TypeError, "string expected");
}
%typemap(in) const string & (std::string temp) {
if (SCHEME_STRINGP($input)) {
temp = std::string(SCHEME_STR_VAL($input));
temp.assign(SCHEME_STR_VAL($input));
$1 = &temp;
} else {
SWIG_exception(SWIG_TypeError, "string expected");