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

@ -41,7 +41,7 @@ class wstring;
for (jsize i = 0; i < $1_len; ++i) {
conv_buf[i] = $1_pstr[i];
}
$1 = std::wstring(conv_buf, $1_len);
$1.assign(conv_buf, $1_len);
delete [] conv_buf;
}
jenv->ReleaseStringChars($input, $1_pstr);
@ -60,7 +60,7 @@ class wstring;
for (jsize i = 0; i < $1_len; ++i) {
conv_buf[i] = $1_pstr[i];
}
$result = std::wstring(conv_buf, $1_len);
$result.assign(conv_buf, $1_len);
delete [] conv_buf;
}
jenv->ReleaseStringChars($input, $1_pstr);
@ -112,7 +112,7 @@ class wstring;
for (jsize i = 0; i < $1_len; ++i) {
conv_buf[i] = $1_pstr[i];
}
$1_str = std::wstring(conv_buf, $1_len);
$1_str.assign(conv_buf, $1_len);
delete [] conv_buf;
}
$1 = &$1_str;
@ -133,7 +133,7 @@ class wstring;
for (jsize i = 0; i < $1_len; ++i) {
conv_buf[i] = $1_pstr[i];
}
$1_str = std::wstring(conv_buf, $1_len);
$1_str.assign(conv_buf, $1_len);
delete [] conv_buf;
}
$result = &$1_str;