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:
parent
ef4ca158de
commit
c836c81acb
11 changed files with 46 additions and 45 deletions
|
|
@ -32,7 +32,7 @@ namespace std {
|
|||
%typemap(in) string (char* tempptr) {
|
||||
if (gh_string_p($input)) {
|
||||
tempptr = SWIG_scm2str($input);
|
||||
$1 = std::string(tempptr);
|
||||
$1.assign(tempptr);
|
||||
if (tempptr) SWIG_free(tempptr);
|
||||
} else {
|
||||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
|
|
@ -43,7 +43,7 @@ namespace std {
|
|||
char* tempptr) {
|
||||
if (gh_string_p($input)) {
|
||||
tempptr = SWIG_scm2str($input);
|
||||
temp = std::string(tempptr);
|
||||
temp.assign(tempptr);
|
||||
if (tempptr) SWIG_free(tempptr);
|
||||
$1 = &temp;
|
||||
} else {
|
||||
|
|
@ -76,7 +76,7 @@ namespace std {
|
|||
%typemap(varin) string {
|
||||
if (gh_string_p($input)) {
|
||||
char *tempptr = SWIG_scm2str($input);
|
||||
$1 = std::string(tempptr);
|
||||
$1.assign(tempptr);
|
||||
if (tempptr) SWIG_free(tempptr);
|
||||
} else {
|
||||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue